From e718f615b8365f331f9f9038d1273ba370e44a06 Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Tue, 12 Oct 2004 21:51:32 +0000 Subject: [PATCH] Whitespace normalization. --- Lib/email/Utils.py | 2 +- Lib/pdb.py | 9 ++++---- Lib/subprocess.py | 46 ++++++++++++++++++------------------- Lib/test/test_subprocess.py | 33 +++++++++++++------------- 4 files changed, 43 insertions(+), 47 deletions(-) diff --git a/Lib/email/Utils.py b/Lib/email/Utils.py index f210eec894b..9ba76011615 100644 --- a/Lib/email/Utils.py +++ b/Lib/email/Utils.py @@ -115,7 +115,7 @@ def formatdate(timeval=None, localtime=False, usegmt=False): returns a date relative to the local timezone instead of UTC, properly taking daylight savings time into account. - Optional argument usegmt means that the timezone is written out as + Optional argument usegmt means that the timezone is written out as an ascii string, not numeric one (so "GMT" instead of "+0000"). This is needed for HTTP, and is only used when localtime==False. """ diff --git a/Lib/pdb.py b/Lib/pdb.py index f07e155eb5c..3c229ab772a 100755 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -946,7 +946,7 @@ Deletes the specified alias.""" into an absolute file name. """ if os.path.isabs(filename) and os.path.exists(filename): - return filename + return filename f = os.path.join(sys.path[0], filename) if os.path.exists(f) and self.canonic(f) == self.mainpyfile: return f @@ -967,8 +967,8 @@ Deletes the specified alias.""" # Start with fresh empty copy of globals and locals and tell the script # that it's being run as __main__ to avoid scripts being able to access # the pdb.py namespace. - globals_ = {"__name__" : "__main__"} - locals_ = globals_ + globals_ = {"__name__" : "__main__"} + locals_ = globals_ # When bdb sets tracing, a number of call and line events happens # BEFORE debugger even reaches user's code (and the exact sequence of @@ -1057,7 +1057,7 @@ def main(): pdb._runscript(mainpyfile) if pdb._user_requested_quit: break - print "The program finished and will be restarted" + print "The program finished and will be restarted" except SystemExit: # In most cases SystemExit does not warrant a post-mortem session. print "The program exited via sys.exit(). Exit status: ", @@ -1076,4 +1076,3 @@ def main(): # When invoked as main program, invoke the debugger on a script if __name__=='__main__': main() - diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 20ced686d09..e729db46af0 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1,6 +1,6 @@ # subprocess - Subprocesses with accessible I/O streams # -# For more information about this module, see PEP 324. +# For more information about this module, see PEP 324. # # Copyright (c) 2003-2004 by Peter Astrand # @@ -174,7 +174,7 @@ communicate(input=None) terminate. The optional stdin argument should be a string to be sent to the child process, or None, if no data should be sent to the child. - + communicate() returns a tuple (stdout, stderr). Note: The data read is buffered in memory, so do not use this @@ -262,7 +262,7 @@ except OSError, e: Replacing os.spawn* ------------------- -P_NOWAIT example: +P_NOWAIT example: pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg") ==> @@ -276,21 +276,21 @@ retcode = os.spawnlp(os.P_WAIT, "/bin/mycmd", "mycmd", "myarg") retcode = call(["/bin/mycmd", "myarg"]) -Vector example: +Vector example: os.spawnvp(os.P_NOWAIT, path, args) ==> Popen([path] + args[1:]) -Environment example: +Environment example: os.spawnlpe(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg", env) ==> Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"}) -Replacing os.popen* +Replacing os.popen* ------------------- pipe = os.popen(cmd, mode='r', bufsize) ==> @@ -352,7 +352,7 @@ except that: * the capturestderr argument is replaced with the stderr argument. * stdin=PIPE and stdout=PIPE must be specified. * popen2 closes all filedescriptors by default, but you have to specify - close_fds=True with subprocess.Popen. + close_fds=True with subprocess.Popen. """ @@ -468,10 +468,10 @@ def list2cmdline(seq): for c in arg: if c == '\\': - # Don't know if we need to double yet. + # Don't know if we need to double yet. bs_buf.append(c) elif c == '"': - # Double backspaces. + # Double backspaces. result.append('\\' * len(bs_buf)*2) bs_buf = [] result.append('\\"') @@ -482,7 +482,7 @@ def list2cmdline(seq): bs_buf = [] result.append(c) - # Add remaining backspaces, if any. + # Add remaining backspaces, if any. if bs_buf: result.extend(bs_buf) @@ -513,7 +513,7 @@ class Popen(object): if creationflags != 0: raise ValueError("creationflags is only supported on Windows platforms") - self.stdin = None + self.stdin = None self.stdout = None self.stderr = None self.pid = None @@ -534,7 +534,7 @@ class Popen(object): # are file descriptors on both platforms. The parent objects # are None when not using PIPEs. The child objects are None # when not redirecting. - + (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) = self._get_handles(stdin, stdout, stderr) @@ -558,7 +558,7 @@ class Popen(object): self.stderr = os.fdopen(errread, 'rU', bufsize) else: self.stderr = os.fdopen(errread, 'rb', bufsize) - + _active.append(self) @@ -578,7 +578,7 @@ class Popen(object): """ if stdin == None and stdout == None and stderr == None: return (None, None, None, None, None, None) - + p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None @@ -651,7 +651,7 @@ class Popen(object): "for Popen to work with your shell or platform.") return w9xpopen - + def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, @@ -685,7 +685,7 @@ class Popen(object): if startupinfo == None: startupinfo = STARTUPINFO() if not None in (p2cread, c2pwrite, errwrite): - startupinfo.dwFlags |= STARTF_USESTDHANDLES + startupinfo.dwFlags |= STARTF_USESTDHANDLES startupinfo.hStdInput = p2cread startupinfo.hStdOutput = c2pwrite startupinfo.hStdError = errwrite @@ -724,7 +724,7 @@ class Popen(object): if errwrite != None: errwrite.Close() - + def poll(self): """Check if child process has terminated. Returns returncode attribute.""" @@ -830,7 +830,7 @@ class Popen(object): c2pwrite = stdout else: # Assuming file-like object - c2pwrite = stdout.fileno() + c2pwrite = stdout.fileno() if stderr == None: pass @@ -867,8 +867,8 @@ class Popen(object): os.close(i) except: pass - - + + def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, @@ -976,7 +976,7 @@ class Popen(object): _active.remove(self) - + def poll(self): """Check if child process has terminated. Returns returncode attribute.""" @@ -1022,7 +1022,7 @@ class Popen(object): self.stdin.close() if self.stdout: read_set.append(self.stdout) - stdout = [] + stdout = [] if self.stderr: read_set.append(self.stderr) stderr = [] @@ -1137,5 +1137,3 @@ if __name__ == "__main__": _demo_windows() else: _demo_posix() - - diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 348da574bec..c2304fbe1fb 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -26,7 +26,7 @@ class ProcessTestCase(unittest.TestCase): else: fname = tempfile.mktemp() return os.open(fname, os.O_RDWR|os.O_CREAT), fname - + # # Generic tests # @@ -85,7 +85,7 @@ class ProcessTestCase(unittest.TestCase): def test_stdin_filedes(self): """stdin is set to open file descriptor""" - tf = tempfile.TemporaryFile() + tf = tempfile.TemporaryFile() d = tf.fileno() os.write(d, "pear") os.lseek(d, 0, 0) @@ -115,7 +115,7 @@ class ProcessTestCase(unittest.TestCase): def test_stdout_filedes(self): """stdout is set to open file descriptor""" - tf = tempfile.TemporaryFile() + tf = tempfile.TemporaryFile() d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], @@ -126,7 +126,7 @@ class ProcessTestCase(unittest.TestCase): def test_stdout_fileobj(self): """stdout is set to open file object""" - tf = tempfile.TemporaryFile() + tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stdout.write("orange")'], stdout=tf) @@ -143,7 +143,7 @@ class ProcessTestCase(unittest.TestCase): def test_stderr_filedes(self): """stderr is set to open file descriptor""" - tf = tempfile.TemporaryFile() + tf = tempfile.TemporaryFile() d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], @@ -154,7 +154,7 @@ class ProcessTestCase(unittest.TestCase): def test_stderr_fileobj(self): """stderr is set to open file object""" - tf = tempfile.TemporaryFile() + tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=tf) @@ -230,7 +230,7 @@ class ProcessTestCase(unittest.TestCase): def test_communicate_pipe_buf(self): """communicate() with writes larger than pipe_buf""" # This test will probably deadlock rather than fail, if - # communicate() does not work properly. + # communicate() does not work properly. x, y = os.pipe() if mswindows: pipe_buf = 512 @@ -239,7 +239,7 @@ class ProcessTestCase(unittest.TestCase): os.close(x) os.close(y) p = subprocess.Popen([sys.executable, "-c", - 'import sys,os;' + 'import sys,os;' 'sys.stdout.write(sys.stdin.read(47));' \ 'sys.stderr.write("xyz"*%d);' \ 'sys.stdout.write(sys.stdin.read())' % pipe_buf], @@ -258,7 +258,7 @@ class ProcessTestCase(unittest.TestCase): (stdout, stderr) = p.communicate("split") self.assertEqual(stdout, "bananasplit") self.assertEqual(stderr, "") - + def test_universal_newlines(self): """universal newlines""" p = subprocess.Popen([sys.executable, "-c", @@ -354,7 +354,7 @@ class ProcessTestCase(unittest.TestCase): self.assertEqual(p.wait(), 0) # Subsequent invocations should just return the returncode self.assertEqual(p.wait(), 0) - + # # POSIX tests # @@ -370,7 +370,7 @@ class ProcessTestCase(unittest.TestCase): self.assertNotEqual(e.child_traceback.find("os.chdir"), -1) else: self.fail("Expected OSError") - + def test_run_abort(self): """returncode handles signal termination""" p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) @@ -394,7 +394,7 @@ class ProcessTestCase(unittest.TestCase): 'import sys,os;' \ 'sys.stdout.write(str(os.dup(0)))'], stdout=subprocess.PIPE, close_fds=1) - # When all fds are closed, the next free fd should be 3. + # When all fds are closed, the next free fd should be 3. self.assertEqual(p.stdout.read(), "3") def test_args_string(self): @@ -446,7 +446,7 @@ class ProcessTestCase(unittest.TestCase): rc = subprocess.call(fname) self.assertEqual(rc, 47) - + # # Windows tests # @@ -454,7 +454,7 @@ class ProcessTestCase(unittest.TestCase): def test_startupinfo(self): """startupinfo argument""" # We uses hardcoded constants, because we do not want to - # depend on win32all. + # depend on win32all. STARTF_USESHOWWINDOW = 1 SW_MAXIMIZE = 3 startupinfo = subprocess.STARTUPINFO() @@ -486,7 +486,7 @@ class ProcessTestCase(unittest.TestCase): newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen(["set"], shell=1, - stdout=subprocess.PIPE, + stdout=subprocess.PIPE, env=newenv) self.assertNotEqual(p.stdout.read().find("physalis"), -1) @@ -495,7 +495,7 @@ class ProcessTestCase(unittest.TestCase): newenv = os.environ.copy() newenv["FRUIT"] = "physalis" p = subprocess.Popen("set", shell=1, - stdout=subprocess.PIPE, + stdout=subprocess.PIPE, env=newenv) self.assertNotEqual(p.stdout.read().find("physalis"), -1) @@ -511,4 +511,3 @@ def test_main(): if __name__ == "__main__": test_main() -