Whitespace normalization.

This commit is contained in:
Tim Peters 2004-10-12 21:51:32 +00:00
parent 4eb59782a8
commit e718f615b8
4 changed files with 43 additions and 47 deletions

View file

@ -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.
"""

View file

@ -946,7 +946,7 @@ def lookupmodule(self, filename):
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 @@ def _runscript(self, filename):
# 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()

View file

@ -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 <astrand@lysator.liu.se>
#
@ -174,7 +174,7 @@ class Popen(args, bufsize=0, executable=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 @@ class Popen(args, bufsize=0, executable=None,
Replacing os.spawn*
-------------------
P_NOWAIT example:
P_NOWAIT example:
pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg")
==>
@ -276,21 +276,21 @@ class Popen(args, bufsize=0, executable=None,
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 @@ class Popen(args, bufsize=0, executable=None,
* 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 @@ def __init__(self, args, bufsize=0, executable=None,
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 @@ def __init__(self, args, bufsize=0, executable=None,
# 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 @@ def __init__(self, args, bufsize=0, executable=None,
self.stderr = os.fdopen(errread, 'rU', bufsize)
else:
self.stderr = os.fdopen(errread, 'rb', bufsize)
_active.append(self)
@ -578,7 +578,7 @@ def _get_handles(self, stdin, stdout, stderr):
"""
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 @@ def _find_w9xpopen(self):
"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 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
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 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
if errwrite != None:
errwrite.Close()
def poll(self):
"""Check if child process has terminated. Returns returncode
attribute."""
@ -830,7 +830,7 @@ def _get_handles(self, stdin, stdout, stderr):
c2pwrite = stdout
else:
# Assuming file-like object
c2pwrite = stdout.fileno()
c2pwrite = stdout.fileno()
if stderr == None:
pass
@ -867,8 +867,8 @@ def _close_fds(self, but):
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 @@ def _handle_exitstatus(self, sts):
_active.remove(self)
def poll(self):
"""Check if child process has terminated. Returns returncode
attribute."""
@ -1022,7 +1022,7 @@ def communicate(self, input=None):
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 @@ def _demo_windows():
_demo_windows()
else:
_demo_posix()

View file

@ -26,7 +26,7 @@ def mkstemp(self):
else:
fname = tempfile.mktemp()
return os.open(fname, os.O_RDWR|os.O_CREAT), fname
#
# Generic tests
#
@ -85,7 +85,7 @@ def test_stdin_pipe(self):
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 @@ def test_stdout_pipe(self):
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 @@ def test_stdout_filedes(self):
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 @@ def test_stderr_pipe(self):
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 @@ def test_stderr_filedes(self):
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 @@ def test_communicate_returns(self):
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 @@ def test_communicate_pipe_buf(self):
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 @@ def test_writes_before_communicate(self):
(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 @@ def test_wait(self):
self.assertEqual(p.wait(), 0)
# Subsequent invocations should just return the returncode
self.assertEqual(p.wait(), 0)
#
# POSIX tests
#
@ -370,7 +370,7 @@ def test_exceptions(self):
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 @@ def test_close_fds(self):
'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 @@ def test_call_string(self):
rc = subprocess.call(fname)
self.assertEqual(rc, 47)
#
# Windows tests
#
@ -454,7 +454,7 @@ def test_call_string(self):
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 @@ def test_shell_sequence(self):
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 @@ def test_shell_string(self):
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()