summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorPeter Astrand <astrand@lysator.liu.se>2005-02-10 08:32:50 (GMT)
committerPeter Astrand <astrand@lysator.liu.se>2005-02-10 08:32:50 (GMT)
commitd38ddf4ca23824f375e627bda82ffa995344c6e5 (patch)
treead7c52db504ddeb2b03cd64eecfce78280666da1 /Lib
parentb615bf06813022dccba98309cdfb77f409c4742f (diff)
downloadcpython-d38ddf4ca23824f375e627bda82ffa995344c6e5.zip
cpython-d38ddf4ca23824f375e627bda82ffa995344c6e5.tar.gz
cpython-d38ddf4ca23824f375e627bda82ffa995344c6e5.tar.bz2
Patch from Leandro Lucarella: replaced:
var == None and var != None with var is None and var is not None and type(var) == int with instanceof(var, int) ...as recomended in PEP 8 [1].
Diffstat (limited to 'Lib')
-rw-r--r--Lib/subprocess.py58
1 files changed, 29 insertions, 29 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index da63148..4cf67ac 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -623,42 +623,42 @@ class Popen(object):
"""Construct and return tupel with IO objects:
p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
"""
- if stdin == None and stdout == None and stderr == None:
+ if stdin is None and stdout is None and stderr is None:
return (None, None, None, None, None, None)
p2cread, p2cwrite = None, None
c2pread, c2pwrite = None, None
errread, errwrite = None, None
- if stdin == None:
+ if stdin is None:
p2cread = GetStdHandle(STD_INPUT_HANDLE)
elif stdin == PIPE:
p2cread, p2cwrite = CreatePipe(None, 0)
# Detach and turn into fd
p2cwrite = p2cwrite.Detach()
p2cwrite = msvcrt.open_osfhandle(p2cwrite, 0)
- elif type(stdin) == int:
+ elif isinstance(stdin, int):
p2cread = msvcrt.get_osfhandle(stdin)
else:
# Assuming file-like object
p2cread = msvcrt.get_osfhandle(stdin.fileno())
p2cread = self._make_inheritable(p2cread)
- if stdout == None:
+ if stdout is None:
c2pwrite = GetStdHandle(STD_OUTPUT_HANDLE)
elif stdout == PIPE:
c2pread, c2pwrite = CreatePipe(None, 0)
# Detach and turn into fd
c2pread = c2pread.Detach()
c2pread = msvcrt.open_osfhandle(c2pread, 0)
- elif type(stdout) == int:
+ elif isinstance(stdout, int):
c2pwrite = msvcrt.get_osfhandle(stdout)
else:
# Assuming file-like object
c2pwrite = msvcrt.get_osfhandle(stdout.fileno())
c2pwrite = self._make_inheritable(c2pwrite)
- if stderr == None:
+ if stderr is None:
errwrite = GetStdHandle(STD_ERROR_HANDLE)
elif stderr == PIPE:
errread, errwrite = CreatePipe(None, 0)
@@ -667,7 +667,7 @@ class Popen(object):
errread = msvcrt.open_osfhandle(errread, 0)
elif stderr == STDOUT:
errwrite = c2pwrite
- elif type(stderr) == int:
+ elif isinstance(stderr, int):
errwrite = msvcrt.get_osfhandle(stderr)
else:
# Assuming file-like object
@@ -715,7 +715,7 @@ class Popen(object):
# Process startup details
default_startupinfo = STARTUPINFO()
- if startupinfo == None:
+ if startupinfo is None:
startupinfo = default_startupinfo
if not None in (p2cread, c2pwrite, errwrite):
startupinfo.dwFlags |= STARTF_USESTDHANDLES
@@ -774,18 +774,18 @@ class Popen(object):
# output pipe are maintained in this process or else the
# pipe will not close when the child process exits and the
# ReadFile will hang.
- if p2cread != None:
+ if p2cread is not None:
p2cread.Close()
- if c2pwrite != None:
+ if c2pwrite is not None:
c2pwrite.Close()
- if errwrite != None:
+ if errwrite is not None:
errwrite.Close()
def poll(self):
"""Check if child process has terminated. Returns returncode
attribute."""
- if self.returncode == None:
+ if self.returncode is None:
if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0:
self.returncode = GetExitCodeProcess(self._handle)
_active.remove(self)
@@ -795,7 +795,7 @@ class Popen(object):
def wait(self):
"""Wait for child process to terminate. Returns returncode
attribute."""
- if self.returncode == None:
+ if self.returncode is None:
obj = WaitForSingleObject(self._handle, INFINITE)
self.returncode = GetExitCodeProcess(self._handle)
_active.remove(self)
@@ -831,7 +831,7 @@ class Popen(object):
stderr_thread.start()
if self.stdin:
- if input != None:
+ if input is not None:
self.stdin.write(input)
self.stdin.close()
@@ -841,9 +841,9 @@ class Popen(object):
stderr_thread.join()
# All data exchanged. Translate lists into strings.
- if stdout != None:
+ if stdout is not None:
stdout = stdout[0]
- if stderr != None:
+ if stderr is not None:
stderr = stderr[0]
# Translate newlines, if requested. We cannot let the file
@@ -871,33 +871,33 @@ class Popen(object):
c2pread, c2pwrite = None, None
errread, errwrite = None, None
- if stdin == None:
+ if stdin is None:
pass
elif stdin == PIPE:
p2cread, p2cwrite = os.pipe()
- elif type(stdin) == int:
+ elif isinstance(stdin, int):
p2cread = stdin
else:
# Assuming file-like object
p2cread = stdin.fileno()
- if stdout == None:
+ if stdout is None:
pass
elif stdout == PIPE:
c2pread, c2pwrite = os.pipe()
- elif type(stdout) == int:
+ elif isinstance(stdout, int):
c2pwrite = stdout
else:
# Assuming file-like object
c2pwrite = stdout.fileno()
- if stderr == None:
+ if stderr is None:
pass
elif stderr == PIPE:
errread, errwrite = os.pipe()
elif stderr == STDOUT:
errwrite = c2pwrite
- elif type(stderr) == int:
+ elif isinstance(stderr, int):
errwrite = stderr
else:
# Assuming file-like object
@@ -942,7 +942,7 @@ class Popen(object):
if shell:
args = ["/bin/sh", "-c"] + args
- if executable == None:
+ if executable is None:
executable = args[0]
# For transferring possible exec failure from child to parent
@@ -985,13 +985,13 @@ class Popen(object):
if close_fds:
self._close_fds(but=errpipe_write)
- if cwd != None:
+ if cwd is not None:
os.chdir(cwd)
if preexec_fn:
apply(preexec_fn)
- if env == None:
+ if env is None:
os.execvp(executable, args)
else:
os.execvpe(executable, args, env)
@@ -1042,7 +1042,7 @@ class Popen(object):
def poll(self):
"""Check if child process has terminated. Returns returncode
attribute."""
- if self.returncode == None:
+ if self.returncode is None:
try:
pid, sts = os.waitpid(self.pid, os.WNOHANG)
if pid == self.pid:
@@ -1055,7 +1055,7 @@ class Popen(object):
def wait(self):
"""Wait for child process to terminate. Returns returncode
attribute."""
- if self.returncode == None:
+ if self.returncode is None:
pid, sts = os.waitpid(self.pid, 0)
self._handle_exitstatus(sts)
return self.returncode
@@ -1117,9 +1117,9 @@ class Popen(object):
stderr.append(data)
# All data exchanged. Translate lists into strings.
- if stdout != None:
+ if stdout is not None:
stdout = ''.join(stdout)
- if stderr != None:
+ if stderr is not None:
stderr = ''.join(stderr)
# Translate newlines, if requested. We cannot let the file