summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/aifc.py3
-rw-r--r--Lib/bdb.py2
-rw-r--r--Lib/binhex.py3
-rw-r--r--Lib/cgitb.py6
-rw-r--r--Lib/formatter.py3
-rw-r--r--Lib/idlelib/CallTips.py6
-rw-r--r--Lib/idlelib/Debugger.py3
-rw-r--r--Lib/imputil.py5
-rw-r--r--Lib/inspect.py42
-rw-r--r--Lib/modulefinder.py3
-rw-r--r--Lib/os.py62
-rwxr-xr-xLib/pdb.py7
-rw-r--r--Lib/plat-irix6/flp.py6
-rw-r--r--Lib/plat-mac/findertools.py9
-rw-r--r--Lib/popen2.py205
-rw-r--r--Lib/pprint.py5
-rwxr-xr-xLib/pydoc.py34
-rw-r--r--Lib/sunau.py3
-rw-r--r--Lib/test/inspect_fodder.py2
-rw-r--r--Lib/test/inspect_fodder2.py4
-rwxr-xr-xLib/test/regrtest.py3
-rw-r--r--Lib/test/test___all__.py3
-rw-r--r--Lib/test/test_compile.py34
-rw-r--r--Lib/test/test_complex_args.py91
-rw-r--r--Lib/test/test_grammar.py49
-rw-r--r--Lib/test/test_inspect.py17
-rw-r--r--Lib/test/test_itertools.py2
-rw-r--r--Lib/test/test_math.py10
-rw-r--r--Lib/test/test_popen2.py98
-rw-r--r--Lib/test/test_scope.py7
-rw-r--r--Lib/test/test_sort.py2
-rw-r--r--Lib/test/test_threadsignals.py6
-rw-r--r--Lib/threading.py5
-rw-r--r--Lib/tokenize.py3
-rw-r--r--Lib/urlparse.py6
-rw-r--r--Lib/wave.py3
36 files changed, 107 insertions, 645 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py
index bc82f48..4e88256 100644
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -665,7 +665,8 @@ class Aifc_write:
## raise Error, 'cannot change parameters after starting to write'
## self._version = version
- def setparams(self, (nchannels, sampwidth, framerate, nframes, comptype, compname)):
+ def setparams(self, params):
+ nchannels, sampwidth, framerate, nframes, comptype, compname = params
if self._nframeswritten:
raise Error, 'cannot change parameters after starting to write'
if comptype not in ('NONE', 'ULAW', 'ALAW', 'G722'):
diff --git a/Lib/bdb.py b/Lib/bdb.py
index d49e7e3..fddc3e6 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -151,7 +151,7 @@ class Bdb:
"""This method is called when a return trap is set here."""
pass
- def user_exception(self, frame, (exc_type, exc_value, exc_traceback)):
+ def user_exception(self, frame, exc_info):
"""This method is called if an exception occurs,
but only if we are to stop at or just below this level."""
pass
diff --git a/Lib/binhex.py b/Lib/binhex.py
index 0f3e3c4..69ac097 100644
--- a/Lib/binhex.py
+++ b/Lib/binhex.py
@@ -170,7 +170,8 @@ class _Rlecoderengine:
del self.ofp
class BinHex:
- def __init__(self, (name, finfo, dlen, rlen), ofp):
+ def __init__(self, name_finfo_dlen_rlen, ofp):
+ name, finfo, dlen, rlen = name_finfo_dlen_rlen
if type(ofp) == type(''):
ofname = ofp
ofp = open(ofname, 'w')
diff --git a/Lib/cgitb.py b/Lib/cgitb.py
index 19118ea..3f36ab1 100644
--- a/Lib/cgitb.py
+++ b/Lib/cgitb.py
@@ -94,10 +94,11 @@ def scanvars(reader, frame, locals):
lasttoken = token
return vars
-def html((etype, evalue, etb), context=5):
+def html(einfo, context=5):
"""Return a nice HTML document describing a given traceback."""
import os, types, time, traceback, linecache, inspect, pydoc
+ etype, evalue, etb = einfo
if type(etype) is types.ClassType:
etype = etype.__name__
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
@@ -184,10 +185,11 @@ function calls leading up to the error, in the order they occurred.</p>'''
-->
''' % ''.join(traceback.format_exception(etype, evalue, etb))
-def text((etype, evalue, etb), context=5):
+def text(einfo, context=5):
"""Return a plain text document describing a given traceback."""
import os, types, time, traceback, linecache, inspect, pydoc
+ etype, evalue, etb = einfo
if type(etype) is types.ClassType:
etype = etype.__name__
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
diff --git a/Lib/formatter.py b/Lib/formatter.py
index 50a9cd8..99b4740 100644
--- a/Lib/formatter.py
+++ b/Lib/formatter.py
@@ -228,7 +228,8 @@ class AbstractFormatter:
self.align = None
self.writer.new_alignment(None)
- def push_font(self, (size, i, b, tt)):
+ def push_font(self, font):
+ size, i, b, tt = font
if self.softspace:
self.hard_break = self.para_end = self.softspace = 0
self.nospace = 1
diff --git a/Lib/idlelib/CallTips.py b/Lib/idlelib/CallTips.py
index 9152eaa..6f362f9 100644
--- a/Lib/idlelib/CallTips.py
+++ b/Lib/idlelib/CallTips.py
@@ -183,7 +183,6 @@ if __name__=='__main__':
def t4(*args): "(...)"
def t5(a, *args): "(a, ...)"
def t6(a, b=None, *args, **kw): "(a, b=None, ..., ***)"
- def t7((a, b), c, (d, e)): "(<tuple>, c, <tuple>)"
class TC(object):
"(ai=None, ...)"
@@ -194,7 +193,6 @@ if __name__=='__main__':
def t4(self, *args): "(...)"
def t5(self, ai, *args): "(ai, ...)"
def t6(self, ai, b=None, *args, **kw): "(ai, b=None, ..., ***)"
- def t7(self, (ai, b), c, (d, e)): "(<tuple>, c, <tuple>)"
def test(tests):
ct = CallTips()
@@ -215,7 +213,7 @@ if __name__=='__main__':
print("%d of %d tests failed" % (len(failed), len(tests)))
tc = TC()
- tests = (t1, t2, t3, t4, t5, t6, t7,
- TC, tc.t1, tc.t2, tc.t3, tc.t4, tc.t5, tc.t6, tc.t7)
+ tests = (t1, t2, t3, t4, t5, t6,
+ TC, tc.t1, tc.t2, tc.t3, tc.t4, tc.t5, tc.t6)
test(tests)
diff --git a/Lib/idlelib/Debugger.py b/Lib/idlelib/Debugger.py
index df691ed..3dbe23d 100644
--- a/Lib/idlelib/Debugger.py
+++ b/Lib/idlelib/Debugger.py
@@ -253,7 +253,8 @@ class Debugger:
if self.vsource.get():
self.sync_source_line()
- def show_frame(self, (frame, lineno)):
+ def show_frame(self, stackitem):
+ frame, lineno = stackitem
self.frame = frame
self.show_variables()
diff --git a/Lib/imputil.py b/Lib/imputil.py
index 88d288f..213799f 100644
--- a/Lib/imputil.py
+++ b/Lib/imputil.py
@@ -278,7 +278,10 @@ class Importer:
setattr(parent, modname, module)
return module
- def _process_result(self, (ispkg, code, values), fqname):
+ def _process_result(self, result, fqname):
+ # unpack result
+ ispkg, code, values = result
+
# did get_code() return an actual module? (rather than a code object)
is_module = isinstance(code, _ModuleType)
diff --git a/Lib/inspect.py b/Lib/inspect.py
index ff25be7..d2546f1 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -366,8 +366,8 @@ def getfile(object):
def getmoduleinfo(path):
"""Get the module name, suffix, mode, and module type for a given file."""
filename = os.path.basename(path)
- suffixes = map(lambda (suffix, mode, mtype):
- (-len(suffix), suffix, mode, mtype), imp.get_suffixes())
+ suffixes = [(-len(suffix), suffix, mode, mtype)
+ for suffix, mode, mtype in imp.get_suffixes()]
suffixes.sort() # try longest suffixes first, in case they overlap
for neglen, suffix, mode, mtype in suffixes:
if filename[neglen:] == suffix:
@@ -568,7 +568,7 @@ class BlockFinder:
self.passline = False
self.last = 1
- def tokeneater(self, type, token, (srow, scol), (erow, ecol), line):
+ def tokeneater(self, type, token, srowcol, erowcol, line):
if not self.started:
# look for the first "def", "class" or "lambda"
if token in ("def", "class", "lambda"):
@@ -578,7 +578,7 @@ class BlockFinder:
self.passline = True # skip to the end of the line
elif type == tokenize.NEWLINE:
self.passline = False # stop skipping when a NEWLINE is seen
- self.last = srow
+ self.last = srowcol[0]
if self.islambda: # lambdas always end at the first NEWLINE
raise EndOfBlock
elif self.passline:
@@ -698,40 +698,6 @@ def _getfullargs(co):
kwonlyargs = list(names[nargs:nargs+nkwargs])
step = 0
- # The following acrobatics are for anonymous (tuple) arguments.
- for i in range(nargs):
- if args[i][:1] in ('', '.'):
- stack, remain, count = [], [], []
- while step < len(code):
- op = ord(code[step])
- step = step + 1
- if op >= dis.HAVE_ARGUMENT:
- opname = dis.opname[op]
- value = ord(code[step]) + ord(code[step+1])*256
- step = step + 2
- if opname in ('UNPACK_TUPLE', 'UNPACK_SEQUENCE'):
- remain.append(value)
- count.append(value)
- elif opname == 'STORE_FAST':
- stack.append(names[value])
-
- # Special case for sublists of length 1: def foo((bar))
- # doesn't generate the UNPACK_TUPLE bytecode, so if
- # `remain` is empty here, we have such a sublist.
- if not remain:
- stack[0] = [stack[0]]
- break
- else:
- remain[-1] = remain[-1] - 1
- while remain[-1] == 0:
- remain.pop()
- size = count.pop()
- stack[-size:] = [stack[-size:]]
- if not remain: break
- remain[-1] = remain[-1] - 1
- if not remain: break
- args[i] = stack[0]
-
nargs += nkwargs
varargs = None
if co.co_flags & CO_VARARGS:
diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py
index 5145f72..160e82f 100644
--- a/Lib/modulefinder.py
+++ b/Lib/modulefinder.py
@@ -279,7 +279,8 @@ class ModuleFinder:
self.msgout(3, "import_module ->", m)
return m
- def load_module(self, fqname, fp, pathname, (suffix, mode, type)):
+ def load_module(self, fqname, fp, pathname, file_info):
+ suffix, mode, type = file_info
self.msgin(2, "load_module", fqname, fp and "fp", pathname)
if type == imp.PKG_DIRECTORY:
m = self.load_package(fqname, pathname)
diff --git a/Lib/os.py b/Lib/os.py
index 268b3cf..5ddf07c 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -653,68 +653,6 @@ otherwise return -SIG, where SIG is the signal that killed it. """
__all__.extend(["spawnvp", "spawnvpe", "spawnlp", "spawnlpe",])
-
-# Supply popen2 etc. (for Unix)
-if _exists("fork"):
- if not _exists("popen2"):
- def popen2(cmd, mode="t", bufsize=-1):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
- may be a sequence, in which case arguments will be passed directly to
- the program without shell intervention (as with os.spawnv()). If 'cmd'
- is a string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdin, child_stdout) are returned."""
- import warnings
- msg = "os.popen2 is deprecated. Use the subprocess module."
- warnings.warn(msg, DeprecationWarning, stacklevel=2)
-
- import subprocess
- PIPE = subprocess.PIPE
- p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
- stdin=PIPE, stdout=PIPE, close_fds=True)
- return p.stdin, p.stdout
- __all__.append("popen2")
-
- if not _exists("popen3"):
- def popen3(cmd, mode="t", bufsize=-1):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
- may be a sequence, in which case arguments will be passed directly to
- the program without shell intervention (as with os.spawnv()). If 'cmd'
- is a string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdin, child_stdout, child_stderr) are returned."""
- import warnings
- msg = "os.popen3 is deprecated. Use the subprocess module."
- warnings.warn(msg, DeprecationWarning, stacklevel=2)
-
- import subprocess
- PIPE = subprocess.PIPE
- p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
- stdin=PIPE, stdout=PIPE, stderr=PIPE,
- close_fds=True)
- return p.stdin, p.stdout, p.stderr
- __all__.append("popen3")
-
- if not _exists("popen4"):
- def popen4(cmd, mode="t", bufsize=-1):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
- may be a sequence, in which case arguments will be passed directly to
- the program without shell intervention (as with os.spawnv()). If 'cmd'
- is a string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdin, child_stdout_stderr) are returned."""
- import warnings
- msg = "os.popen4 is deprecated. Use the subprocess module."
- warnings.warn(msg, DeprecationWarning, stacklevel=2)
-
- import subprocess
- PIPE = subprocess.PIPE
- p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
- stdin=PIPE, stdout=PIPE,
- stderr=subprocess.STDOUT, close_fds=True)
- return p.stdin, p.stdout
- __all__.append("popen4")
-
import copy_reg as _copy_reg
def _make_stat_result(tup, dict):
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 3d06b0a..9538f3c 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -180,13 +180,12 @@ class Pdb(bdb.Bdb, cmd.Cmd):
print('--Return--', file=self.stdout)
self.interaction(frame, None)
- def user_exception(self, frame, (exc_type, exc_value, exc_traceback)):
+ def user_exception(self, frame, exc_info):
"""This function is called if an exception occurs,
but only if we are to stop at or just below this level."""
+ exc_type, exc_value, exc_traceback = exc_info
frame.f_locals['__exception__'] = exc_type, exc_value
- if type(exc_type) == type(''):
- exc_type_name = exc_type
- else: exc_type_name = exc_type.__name__
+ exc_type_name = exc_type.__name__
print(exc_type_name + ':', _saferepr(exc_value), file=self.stdout)
self.interaction(frame, exc_traceback)
diff --git a/Lib/plat-irix6/flp.py b/Lib/plat-irix6/flp.py
index d150be0..fee0894 100644
--- a/Lib/plat-irix6/flp.py
+++ b/Lib/plat-irix6/flp.py
@@ -326,7 +326,8 @@ def _parse_object(file):
#
# External - Create a form an link to an instance variable.
#
-def create_full_form(inst, (fdata, odatalist)):
+def create_full_form(inst, formdata):
+ fdata, odatalist = formdata
form = create_form(fdata)
exec('inst.'+fdata.Name+' = form\n')
for odata in odatalist:
@@ -336,7 +337,8 @@ def create_full_form(inst, (fdata, odatalist)):
# External - Merge a form into an existing form in an instance
# variable.
#
-def merge_full_form(inst, form, (fdata, odatalist)):
+def merge_full_form(inst, form, formdata):
+ fdata, odatalist = formdata
exec('inst.'+fdata.Name+' = form\n')
if odatalist[0].Class != FL.BOX:
raise error, 'merge_full_form() expects FL.BOX as first obj'
diff --git a/Lib/plat-mac/findertools.py b/Lib/plat-mac/findertools.py
index 6c12419..036c5c5 100644
--- a/Lib/plat-mac/findertools.py
+++ b/Lib/plat-mac/findertools.py
@@ -296,8 +296,9 @@ def location(object, pos=None):
return _getlocation(object_alias)
return _setlocation(object_alias, pos)
-def _setlocation(object_alias, (x, y)):
+def _setlocation(object_alias, location):
"""_setlocation: Set the location of the icon for the object."""
+ x, y = location
finder = _getfinder()
args = {}
attrs = {}
@@ -438,8 +439,9 @@ def windowsize(folder, size=None):
return _getwindowsize(folder_alias)
return _setwindowsize(folder_alias, size)
-def _setwindowsize(folder_alias, (w, h)):
+def _setwindowsize(folder_alias, size):
"""Set the size of a Finder window for folder to (w, h)"""
+ w, h = size
finder = _getfinder()
args = {}
attrs = {}
@@ -489,8 +491,9 @@ def windowposition(folder, pos=None):
pos = (pos.h, pos.v)
return _setwindowposition(folder_alias, pos)
-def _setwindowposition(folder_alias, (x, y)):
+def _setwindowposition(folder_alias, position):
"""Set the size of a Finder window for folder to (w, h)."""
+ x, y = position
finder = _getfinder()
args = {}
attrs = {}
diff --git a/Lib/popen2.py b/Lib/popen2.py
deleted file mode 100644
index 2e25868..0000000
--- a/Lib/popen2.py
+++ /dev/null
@@ -1,205 +0,0 @@
-"""Spawn a command with pipes to its stdin, stdout, and optionally stderr.
-
-The normal os.popen(cmd, mode) call spawns a shell command and provides a
-file interface to just the input or output of the process depending on
-whether mode is 'r' or 'w'. This module provides the functions popen2(cmd)
-and popen3(cmd) which return two or three pipes to the spawned command.
-"""
-
-import os
-import sys
-import warnings
-warnings.warn("The popen2 module is deprecated. Use the subprocess module.",
- DeprecationWarning, stacklevel=2)
-
-__all__ = ["popen2", "popen3", "popen4"]
-
-try:
- MAXFD = os.sysconf('SC_OPEN_MAX')
-except (AttributeError, ValueError):
- MAXFD = 256
-
-_active = []
-
-def _cleanup():
- for inst in _active[:]:
- if inst.poll(_deadstate=sys.maxint) >= 0:
- try:
- _active.remove(inst)
- except ValueError:
- # This can happen if two threads create a new Popen instance.
- # It's harmless that it was already removed, so ignore.
- pass
-
-class Popen3:
- """Class representing a child process. Normally instances are created
- by the factory functions popen2() and popen3()."""
-
- sts = -1 # Child not completed yet
-
- def __init__(self, cmd, capturestderr=False, bufsize=-1):
- """The parameter 'cmd' is the shell command to execute in a
- sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments
- will be passed directly to the program without shell intervention (as
- with os.spawnv()). If 'cmd' is a string it will be passed to the shell
- (as with os.system()). The 'capturestderr' flag, if true, specifies
- that the object should capture standard error output of the child
- process. The default is false. If the 'bufsize' parameter is
- specified, it specifies the size of the I/O buffers to/from the child
- process."""
- _cleanup()
- self.cmd = cmd
- p2cread, p2cwrite = os.pipe()
- c2pread, c2pwrite = os.pipe()
- if capturestderr:
- errout, errin = os.pipe()
- self.pid = os.fork()
- if self.pid == 0:
- # Child
- os.dup2(p2cread, 0)
- os.dup2(c2pwrite, 1)
- if capturestderr:
- os.dup2(errin, 2)
- self._run_child(cmd)
- os.close(p2cread)
- self.tochild = os.fdopen(p2cwrite, 'w', bufsize)
- os.close(c2pwrite)
- self.fromchild = os.fdopen(c2pread, 'r', bufsize)
- if capturestderr:
- os.close(errin)
- self.childerr = os.fdopen(errout, 'r', bufsize)
- else:
- self.childerr = None
-
- def __del__(self):
- # In case the child hasn't been waited on, check if it's done.
- self.poll(_deadstate=sys.maxint)
- if self.sts < 0:
- if _active is not None:
- # Child is still running, keep us alive until we can wait on it.
- _active.append(self)
-
- def _run_child(self, cmd):
- if isinstance(cmd, basestring):
- cmd = ['/bin/sh', '-c', cmd]
- for i in range(3, MAXFD):
- try:
- os.close(i)
- except OSError:
- pass
- try:
- os.execvp(cmd[0], cmd)
- finally:
- os._exit(1)
-
- def poll(self, _deadstate=None):
- """Return the exit status of the child process if it has finished,
- or -1 if it hasn't finished yet."""
- if self.sts < 0:
- try:
- pid, sts = os.waitpid(self.pid, os.WNOHANG)
- # pid will be 0 if self.pid hasn't terminated
- if pid == self.pid:
- self.sts = sts
- except os.error:
- if _deadstate is not None:
- self.sts = _deadstate
- return self.sts
-
- def wait(self):
- """Wait for and return the exit status of the child process."""
- if self.sts < 0:
- pid, sts = os.waitpid(self.pid, 0)
- # This used to be a test, but it is believed to be
- # always true, so I changed it to an assertion - mvl
- assert pid == self.pid
- self.sts = sts
- return self.sts
-
-
-class Popen4(Popen3):
- childerr = None
-
- def __init__(self, cmd, bufsize=-1):
- _cleanup()
- self.cmd = cmd
- p2cread, p2cwrite = os.pipe()
- c2pread, c2pwrite = os.pipe()
- self.pid = os.fork()
- if self.pid == 0:
- # Child
- os.dup2(p2cread, 0)
- os.dup2(c2pwrite, 1)
- os.dup2(c2pwrite, 2)
- self._run_child(cmd)
- os.close(p2cread)
- self.tochild = os.fdopen(p2cwrite, 'w', bufsize)
- os.close(c2pwrite)
- self.fromchild = os.fdopen(c2pread, 'r', bufsize)
-
-
-if sys.platform[:3] == "win" or sys.platform == "os2emx":
- # Some things don't make sense on non-Unix platforms.
- del Popen3, Popen4
-
- def popen2(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout, child_stdin) are returned."""
- w, r = os.popen2(cmd, mode, bufsize)
- return r, w
-
- def popen3(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout, child_stdin, child_stderr) are returned."""
- w, r, e = os.popen3(cmd, mode, bufsize)
- return r, w, e
-
- def popen4(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout_stderr, child_stdin) are returned."""
- w, r = os.popen4(cmd, mode, bufsize)
- return r, w
-else:
- def popen2(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout, child_stdin) are returned."""
- inst = Popen3(cmd, False, bufsize)
- return inst.fromchild, inst.tochild
-
- def popen3(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout, child_stdin, child_stderr) are returned."""
- inst = Popen3(cmd, True, bufsize)
- return inst.fromchild, inst.tochild, inst.childerr
-
- def popen4(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout_stderr, child_stdin) are returned."""
- inst = Popen4(cmd, bufsize)
- return inst.fromchild, inst.tochild
-
- __all__.extend(["Popen3", "Popen4"])
diff --git a/Lib/pprint.py b/Lib/pprint.py
index 7e7ef67..d7f9a28 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -249,7 +249,10 @@ def _safe_repr(object, context, maxlevels, level):
try:
items = sorted(items)
except TypeError:
- items = sorted(items, key=lambda (k, v): (str(type(k)), k, v))
+ def sortkey(item):
+ key, value = item
+ return str(type(key)), key, value
+ items = sorted(items, key=sortkey)
for k, v in items:
krepr, kreadable, krecur = saferepr(k, context, maxlevels, level)
vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level)
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 5e91ad2..0716a3a 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -171,11 +171,12 @@ def visiblename(name, all=None):
def classify_class_attrs(object):
"""Wrap inspect.classify_class_attrs, with fixup for data descriptors."""
- def fixup((name, kind, cls, value)):
+ results = []
+ for (name, kind, cls, value) in inspect.classify_class_attrs(object):
if inspect.isdatadescriptor(value):
kind = 'data descriptor'
- return name, kind, cls, value
- return map(fixup, inspect.classify_class_attrs(object))
+ results.append((name, kind, cls, value))
+ return results
# ----------------------------------------------------- module manipulation
@@ -228,11 +229,9 @@ def synopsis(filename, cache={}):
class ErrorDuringImport(Exception):
"""Errors that occurred while trying to import something to document it."""
- def __init__(self, filename, (exc, value, tb)):
+ def __init__(self, filename, exc_info):
self.filename = filename
- self.exc = exc
- self.value = value
- self.tb = tb
+ self.exc, self.value, self.tb = exc_info
def __str__(self):
exc = self.exc
@@ -502,8 +501,9 @@ class HTMLDoc(Doc):
"""Make a link for a module."""
return '<a href="%s.html">%s</a>' % (object.__name__, object.__name__)
- def modpkglink(self, (name, path, ispackage, shadowed)):
+ def modpkglink(self, modpkginfo):
"""Make a link for a module or package to display in an index."""
+ name, path, ispackage, shadowed = modpkginfo
if shadowed:
return self.grey(name)
if path:
@@ -662,12 +662,12 @@ class HTMLDoc(Doc):
'Package Contents', '#ffffff', '#aa55cc', contents)
elif modules:
contents = self.multicolumn(
- modules, lambda (key, value), s=self: s.modulelink(value))
+ modules, lambda t: self.modulelink(t[1]))
result = result + self.bigsection(
'Modules', '#fffff', '#aa55cc', contents)
if classes:
- classlist = map(lambda (key, value): value, classes)
+ classlist = [value for (key, value) in classes]
contents = [
self.formattree(inspect.getclasstree(classlist, 1), name)]
for key, value in classes:
@@ -768,8 +768,10 @@ class HTMLDoc(Doc):
push('\n')
return attrs
- attrs = filter(lambda (name, kind, cls, value): visiblename(name),
- classify_class_attrs(object))
+ attrs = [(name, kind, cls, value)
+ for name, kind, cls, value in classify_class_attrs(object)
+ if visiblename(name)]
+
mdict = {}
for key, kind, homecls, value in attrs:
mdict[key] = anchor = '#' + name + '-' + key
@@ -1071,7 +1073,7 @@ class TextDoc(Doc):
'PACKAGE CONTENTS', '\n'.join(modpkgs))
if classes:
- classlist = map(lambda (key, value): value, classes)
+ classlist = [value for key, value in classes]
contents = [self.formattree(
inspect.getclasstree(classlist, 1), name)]
for key, value in classes:
@@ -1175,8 +1177,10 @@ class TextDoc(Doc):
name, mod, maxlen=70, doc=doc) + '\n')
return attrs
- attrs = filter(lambda (name, kind, cls, value): visiblename(name),
- classify_class_attrs(object))
+ attrs = [(name, kind, cls, value)
+ for name, kind, cls, value in classify_class_attrs(object)
+ if visiblename(name)]
+
while attrs:
if mro:
thisclass = mro.popleft()
diff --git a/Lib/sunau.py b/Lib/sunau.py
index ba79508..648506c 100644
--- a/Lib/sunau.py
+++ b/Lib/sunau.py
@@ -364,7 +364,8 @@ class Au_write:
else:
return 'not compressed'
- def setparams(self, (nchannels, sampwidth, framerate, nframes, comptype, compname)):
+ def setparams(self, params):
+ nchannels, sampwidth, framerate, nframes, comptype, compname = params
self.setnchannels(nchannels)
self.setsampwidth(sampwidth)
self.setframerate(framerate)
diff --git a/Lib/test/inspect_fodder.py b/Lib/test/inspect_fodder.py
index 823559b..ec96eb7 100644
--- a/Lib/test/inspect_fodder.py
+++ b/Lib/test/inspect_fodder.py
@@ -5,7 +5,7 @@ import sys, inspect
# line 5
# line 7
-def spam(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h):
+def spam(a, b, c, d=3, e=4, f=5, *g, **h):
eggs(b + d, c + f)
# line 11
diff --git a/Lib/test/inspect_fodder2.py b/Lib/test/inspect_fodder2.py
index ef70c09..e49074c 100644
--- a/Lib/test/inspect_fodder2.py
+++ b/Lib/test/inspect_fodder2.py
@@ -60,8 +60,8 @@ def with_comment(): # hello
# line 61
multiline_sig = [
- lambda (x,
- y): x+y,
+ lambda x, \
+ y: x+y,
None,
]
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index 3681a9d..6e52021 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -887,7 +887,6 @@ _expectations = {
test_ossaudiodev
test_poll
test_popen
- test_popen2
test_posix
test_pty
test_pwd
@@ -986,7 +985,6 @@ _expectations = {
test_ntpath
test_openpty
test_poll
- test_popen2
test_pty
test_pwd
test_strop
@@ -1062,7 +1060,6 @@ _expectations = {
test_mmap
test_nis
test_poll
- test_popen2
test_resource
test_sqlite
test_startfile
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index e7ed2f7..2c4e103 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -7,8 +7,6 @@ warnings.filterwarnings("ignore",
"the gopherlib module is deprecated",
DeprecationWarning,
"<string>")
-warnings.filterwarnings("ignore", ".*popen2 module is deprecated.*",
- DeprecationWarning)
class AllTest(unittest.TestCase):
@@ -112,7 +110,6 @@ class AllTest(unittest.TestCase):
self.check_all("pickle")
self.check_all("pickletools")
self.check_all("pipes")
- self.check_all("popen2")
self.check_all("poplib")
self.check_all("posixpath")
self.check_all("pprint")
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 213cca8..4e29eab 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -124,29 +124,9 @@ def f(x):
exec(code, g)
self.assertEqual(g['f'](5), 0)
- def test_complex_args(self):
-
- def comp_args((a, b)):
- return a,b
- self.assertEqual(comp_args((1, 2)), (1, 2))
-
- def comp_args((a, b)=(3, 4)):
- return a, b
- self.assertEqual(comp_args((1, 2)), (1, 2))
- self.assertEqual(comp_args(), (3, 4))
-
- def comp_args(a, (b, c)):
- return a, b, c
- self.assertEqual(comp_args(1, (2, 3)), (1, 2, 3))
-
- def comp_args(a=2, (b, c)=(3, 4)):
- return a, b, c
- self.assertEqual(comp_args(1, (2, 3)), (1, 2, 3))
- self.assertEqual(comp_args(), (2, 3, 4))
-
def test_argument_order(self):
try:
- exec('def f(a=1, (b, c)): pass')
+ exec('def f(a=1, b): pass')
self.fail("non-default args after default")
except SyntaxError:
pass
@@ -394,16 +374,16 @@ if 1:
self.assertEqual((Ellipsis, Ellipsis) in d, False)
def test_annotation_limit(self):
- # 16 bits are available for # of annotations, and the
- # tuple of annotations names is counted, hence 65534
+ # 16 bits are available for # of annotations, but only 8 bits are
+ # available for the parameter count, hence 255
# is the max. Ensure the result of too many annotations is a
# SyntaxError.
- s = "def f((%s)): pass"
- s %= ', '.join('a%d:%d' % (i,i) for i in range(65535))
+ s = "def f(%s): pass"
+ s %= ', '.join('a%d:%d' % (i,i) for i in range(256))
self.assertRaises(SyntaxError, compile, s, '?', 'exec')
# Test that the max # of annotations compiles.
- s = "def f((%s)): pass"
- s %= ', '.join('a%d:%d' % (i,i) for i in range(65534))
+ s = "def f(%s): pass"
+ s %= ', '.join('a%d:%d' % (i,i) for i in range(255))
compile(s, '?', 'exec')
def test_mangling(self):
diff --git a/Lib/test/test_complex_args.py b/Lib/test/test_complex_args.py
deleted file mode 100644
index c6d50a9..0000000
--- a/Lib/test/test_complex_args.py
+++ /dev/null
@@ -1,91 +0,0 @@
-
-import unittest
-from test import test_support
-
-class ComplexArgsTestCase(unittest.TestCase):
-
- def check(self, func, expected, *args):
- self.assertEqual(func(*args), expected)
-
- # These functions are tested below as lambdas too. If you add a function test,
- # also add a similar lambda test.
-
- def test_func_parens_no_unpacking(self):
- def f(((((x))))): return x
- self.check(f, 1, 1)
- # Inner parens are elided, same as: f(x,)
- def f(((x)),): return x
- self.check(f, 2, 2)
-
- def test_func_1(self):
- def f(((((x),)))): return x
- self.check(f, 3, (3,))
- def f(((((x)),))): return x
- self.check(f, 4, (4,))
- def f(((((x))),)): return x
- self.check(f, 5, (5,))
- def f(((x),)): return x
- self.check(f, 6, (6,))
-
- def test_func_2(self):
- def f(((((x)),),)): return x
- self.check(f, 2, ((2,),))
-
- def test_func_3(self):
- def f((((((x)),),),)): return x
- self.check(f, 3, (((3,),),))
-
- def test_func_complex(self):
- def f((((((x)),),),), a, b, c): return x, a, b, c
- self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7)
-
- def f(((((((x)),)),),), a, b, c): return x, a, b, c
- self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7)
-
- def f(a, b, c, ((((((x)),)),),)): return a, b, c, x
- self.check(f, (9, 8, 7, 3), 9, 8, 7, (((3,),),))
-
- # Duplicate the tests above, but for lambda. If you add a lambda test,
- # also add a similar function test above.
-
- def test_lambda_parens_no_unpacking(self):
- f = lambda (((((x))))): x
- self.check(f, 1, 1)
- # Inner parens are elided, same as: f(x,)
- f = lambda ((x)),: x
- self.check(f, 2, 2)
-
- def test_lambda_1(self):
- f = lambda (((((x),)))): x
- self.check(f, 3, (3,))
- f = lambda (((((x)),))): x
- self.check(f, 4, (4,))
- f = lambda (((((x))),)): x
- self.check(f, 5, (5,))
- f = lambda (((x),)): x
- self.check(f, 6, (6,))
-
- def test_lambda_2(self):
- f = lambda (((((x)),),)): x
- self.check(f, 2, ((2,),))
-
- def test_lambda_3(self):
- f = lambda ((((((x)),),),)): x
- self.check(f, 3, (((3,),),))
-
- def test_lambda_complex(self):
- f = lambda (((((x)),),),), a, b, c: (x, a, b, c)
- self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7)
-
- f = lambda ((((((x)),)),),), a, b, c: (x, a, b, c)
- self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7)
-
- f = lambda a, b, c, ((((((x)),)),),): (a, b, c, x)
- self.check(f, (9, 8, 7, 3), 9, 8, 7, (((3,),),))
-
-
-def test_main():
- test_support.run_unittest(ComplexArgsTestCase)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 96cf824..711d636 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -144,51 +144,32 @@ class GrammarTests(unittest.TestCase):
### decorators: decorator+
### parameters: '(' [typedargslist] ')'
### typedargslist: ((tfpdef ['=' test] ',')*
- ### ('*' [tname] (',' tname ['=' test])* [',' '**' tname] | '**' tname)
+ ### ('*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef)
### | tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
- ### tname: NAME [':' test]
- ### tfpdef: tname | '(' tfplist ')'
- ### tfplist: tfpdef (',' tfpdef)* [',']
+ ### tfpdef: NAME [':' test]
### varargslist: ((vfpdef ['=' test] ',')*
- ### ('*' [vname] (',' vname ['=' test])* [',' '**' vname] | '**' vname)
+ ### ('*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef)
### | vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
- ### vname: NAME
- ### vfpdef: vname | '(' vfplist ')'
- ### vfplist: vfpdef (',' vfpdef)* [',']
+ ### vfpdef: NAME
def f1(): pass
f1()
f1(*())
f1(*(), **{})
def f2(one_argument): pass
def f3(two, arguments): pass
- def f4(two, (compound, (argument, list))): pass
- def f5((compound, first), two): pass
self.assertEquals(f2.__code__.co_varnames, ('one_argument',))
self.assertEquals(f3.__code__.co_varnames, ('two', 'arguments'))
- if sys.platform.startswith('java'):
- self.assertEquals(f4.__code__.co_varnames,
- ('two', '(compound, (argument, list))', 'compound', 'argument',
- 'list',))
- self.assertEquals(f5.__code__.co_varnames,
- ('(compound, first)', 'two', 'compound', 'first'))
- else:
- self.assertEquals(f4.__code__.co_varnames,
- ('two', '.1', 'compound', 'argument', 'list'))
- self.assertEquals(f5.__code__.co_varnames,
- ('.0', 'two', 'compound', 'first'))
def a1(one_arg,): pass
def a2(two, args,): pass
def v0(*rest): pass
def v1(a, *rest): pass
def v2(a, b, *rest): pass
- def v3(a, (b, c), *rest): return a, b, c, rest
f1()
f2(1)
f2(1,)
f3(1, 2)
f3(1, 2,)
- f4(1, (2, (3, 4)))
v0()
v0(1)
v0(1,)
@@ -203,17 +184,7 @@ class GrammarTests(unittest.TestCase):
v2(1,2,3)
v2(1,2,3,4)
v2(1,2,3,4,5,6,7,8,9,0)
- v3(1,(2,3))
- v3(1,(2,3),4)
- v3(1,(2,3),4,5,6,7,8,9,0)
-
- # ceval unpacks the formal arguments into the first argcount names;
- # thus, the names nested inside tuples must appear after these names.
- if sys.platform.startswith('java'):
- self.assertEquals(v3.__code__.co_varnames, ('a', '(b, c)', 'rest', 'b', 'c'))
- else:
- self.assertEquals(v3.__code__.co_varnames, ('a', '.1', 'rest', 'b', 'c'))
- self.assertEquals(v3(1, (2, 3), 4), (1, 2, 3, (4,)))
+
def d01(a=1): pass
d01()
d01(1)
@@ -286,10 +257,6 @@ class GrammarTests(unittest.TestCase):
d22v(*(1, 2, 3, 4))
d22v(1, 2, *(3, 4, 5))
d22v(1, *(2, 3), **{'d': 4})
- def d31v((x)): pass
- d31v(1)
- def d32v((x,)): pass
- d32v((1,))
# keyword only argument tests
def pos0key1(*, key): return key
pos0key1(key=100)
@@ -312,12 +279,12 @@ class GrammarTests(unittest.TestCase):
self.assertEquals(f.__annotations__, {'x': float})
def f(x, y:1+2): pass
self.assertEquals(f.__annotations__, {'y': 3})
- def f(a, (b:1, c:2, d)): pass
+ def f(a, b:1, c:2, d): pass
self.assertEquals(f.__annotations__, {'b': 1, 'c': 2})
- def f(a, (b:1, c:2, d), e:3=4, f=5, *g:6): pass
+ def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass
self.assertEquals(f.__annotations__,
{'b': 1, 'c': 2, 'e': 3, 'g': 6})
- def f(a, (b:1, c:2, d), e:3=4, f=5, *g:6, h:7, i=8, j:9=10,
+ def f(a, b:1, c:2, d, e:3=4, f=5, *g:6, h:7, i=8, j:9=10,
**k:11) -> 12: pass
self.assertEquals(f.__annotations__,
{'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9,
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 5e03218..7919931 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -116,11 +116,11 @@ class TestInterpreterStack(IsTestBase):
def test_previous_frame(self):
args, varargs, varkw, locals = inspect.getargvalues(mod.fr.f_back)
- self.assertEqual(args, ['a', 'b', 'c', 'd', ['e', ['f']]])
+ self.assertEqual(args, ['a', 'b', 'c', 'd', 'e', 'f'])
self.assertEqual(varargs, 'g')
self.assertEqual(varkw, 'h')
self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals),
- '(a=7, b=8, c=9, d=3, (e=4, (f=5,)), *g=(), **h={})')
+ '(a=7, b=8, c=9, d=3, e=4, f=5, *g=(), **h={})')
class GetSourceBase(unittest.TestCase):
# Subclasses must override.
@@ -321,9 +321,9 @@ class TestClassesAndFunctions(unittest.TestCase):
self.assertArgSpecEquals(mod.eggs, ['x', 'y'], formatted = '(x, y)')
self.assertArgSpecEquals(mod.spam,
- ['a', 'b', 'c', 'd', ['e', ['f']]],
- 'g', 'h', (3, (4, (5,))),
- '(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h)')
+ ['a', 'b', 'c', 'd', 'e', 'f'],
+ 'g', 'h', (3, 4, 5),
+ '(a, b, c, d=3, e=4, f=5, *g, **h)')
def test_getargspec_method(self):
class A(object):
@@ -331,13 +331,6 @@ class TestClassesAndFunctions(unittest.TestCase):
pass
self.assertArgSpecEquals(A.m, ['self'])
- def test_getargspec_sublistofone(self):
- def sublistOfOne((foo,)): return 1
- self.assertArgSpecEquals(sublistOfOne, [['foo']])
-
- def fakeSublistOfOne((foo)): return 1
- self.assertArgSpecEquals(fakeSublistOfOne, ['foo'])
-
def test_classify_newstyle(self):
class A(object):
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index 765501d..6dfc52e 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -859,7 +859,7 @@ Samuele
# is differencing with a range so that consecutive numbers all appear in
# same group.
>>> data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
->>> for k, g in groupby(enumerate(data), lambda (i,x):i-x):
+>>> for k, g in groupby(enumerate(data), lambda t:t[0]-t[1]):
... print(map(operator.itemgetter(1), g))
...
[1]
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index a45fc34..e5c6ead 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -105,10 +105,11 @@ class MathTests(unittest.TestCase):
def testFrexp(self):
self.assertRaises(TypeError, math.frexp)
- def testfrexp(name, (mant, exp), (emant, eexp)):
+ def testfrexp(name, result, expected):
+ (mant, exp), (emant, eexp) = result, expected
if abs(mant-emant) > eps or exp != eexp:
self.fail('%s returned %r, expected %r'%\
- (name, (mant, exp), (emant,eexp)))
+ (name, result, expected))
testfrexp('frexp(-1)', math.frexp(-1), (-0.5, 1))
testfrexp('frexp(0)', math.frexp(0), (0, 0))
@@ -145,10 +146,11 @@ class MathTests(unittest.TestCase):
def testModf(self):
self.assertRaises(TypeError, math.modf)
- def testmodf(name, (v1, v2), (e1, e2)):
+ def testmodf(name, result, expected):
+ (v1, v2), (e1, e2) = result, expected
if abs(v1-e1) > eps or abs(v2-e2):
self.fail('%s returned %r, expected %r'%\
- (name, (v1,v2), (e1,e2)))
+ (name, result, expected))
testmodf('modf(1.5)', math.modf(1.5), (0.5, 1.0))
testmodf('modf(-1.5)', math.modf(-1.5), (-0.5, -1.0))
diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py
deleted file mode 100644
index 023871f..0000000
--- a/Lib/test/test_popen2.py
+++ /dev/null
@@ -1,98 +0,0 @@
-#! /usr/bin/env python
-"""Test script for popen2.py"""
-
-import warnings
-warnings.filterwarnings("ignore", ".*popen2 module is deprecated.*",
- DeprecationWarning)
-warnings.filterwarnings("ignore", "os\.popen. is deprecated.*",
- DeprecationWarning)
-
-import os
-import sys
-import unittest
-import popen2
-
-from test.test_support import TestSkipped, run_unittest, reap_children
-
-if sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos':
- # Locks get messed up or something. Generally we're supposed
- # to avoid mixing "posix" fork & exec with native threads, and
- # they may be right about that after all.
- raise TestSkipped("popen2() doesn't work on " + sys.platform)
-
-# if we don't have os.popen, check that
-# we have os.fork. if not, skip the test
-# (by raising an ImportError)
-try:
- from os import popen
- del popen
-except ImportError:
- from os import fork
- del fork
-
-class Popen2Test(unittest.TestCase):
- cmd = "cat"
- if os.name == "nt":
- cmd = "more"
- teststr = "ab cd\n"
- # "more" doesn't act the same way across Windows flavors,
- # sometimes adding an extra newline at the start or the
- # end. So we strip whitespace off both ends for comparison.
- expected = teststr.strip()
-
- def setUp(self):
- popen2._cleanup()
- # When the test runs, there shouldn't be any open pipes
- self.assertFalse(popen2._active, "Active pipes when test starts" +
- repr([c.cmd for c in popen2._active]))
-
- def tearDown(self):
- for inst in popen2._active:
- inst.wait()
- popen2._cleanup()
- self.assertFalse(popen2._active, "_active not empty")
- reap_children()
-
- def validate_output(self, teststr, expected_out, r, w, e=None):
- w.write(teststr)
- w.close()
- got = r.read()
- self.assertEquals(expected_out, got.strip(), "wrote %r read %r" %
- (teststr, got))
-
- if e is not None:
- got = e.read()
- self.assertFalse(got, "unexpected %r on stderr" % got)
-
- def test_popen2(self):
- r, w = popen2.popen2(self.cmd)
- self.validate_output(self.teststr, self.expected, r, w)
-
- def test_popen3(self):
- if os.name == 'posix':
- r, w, e = popen2.popen3([self.cmd])
- self.validate_output(self.teststr, self.expected, r, w, e)
-
- r, w, e = popen2.popen3(self.cmd)
- self.validate_output(self.teststr, self.expected, r, w, e)
-
- def test_os_popen2(self):
- # same test as test_popen2(), but using the os.popen*() API
- w, r = os.popen2(self.cmd)
- self.validate_output(self.teststr, self.expected, r, w)
-
- def test_os_popen3(self):
- # same test as test_popen3(), but using the os.popen*() API
- if os.name == 'posix':
- w, r, e = os.popen3([self.cmd])
- self.validate_output(self.teststr, self.expected, r, w, e)
-
- w, r, e = os.popen3(self.cmd)
- self.validate_output(self.teststr, self.expected, r, w, e)
-
-
-def test_main():
- run_unittest(Popen2Test)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py
index f5c1462..259d1d9 100644
--- a/Lib/test/test_scope.py
+++ b/Lib/test/test_scope.py
@@ -323,13 +323,6 @@ else:
self.assertEqual(makeReturner2(a=11)()['a'], 11)
- def makeAddPair((a, b)):
- def addPair((c, d)):
- return (a + c, b + d)
- return addPair
-
- self.assertEqual(makeAddPair((1, 2))((100, 200)), (101,202))
-
def testScopeOfGlobalStmt(self):
# Examples posted by Samuele Pedroni to python-dev on 3/1/2001
diff --git a/Lib/test/test_sort.py b/Lib/test/test_sort.py
index 738ffe1..8ef98c7 100644
--- a/Lib/test/test_sort.py
+++ b/Lib/test/test_sort.py
@@ -184,7 +184,7 @@ class TestDecorateSortUndecorate(unittest.TestCase):
def test_stability(self):
data = [(random.randrange(100), i) for i in range(200)]
copy = data[:]
- data.sort(key=lambda (x,y): x) # sort on the random first field
+ data.sort(key=lambda t: t[0]) # sort on the random first field
copy.sort() # sort using both fields
self.assertEqual(data, copy) # should get the same result
diff --git a/Lib/test/test_threadsignals.py b/Lib/test/test_threadsignals.py
index 1f10fe7..286c2e4 100644
--- a/Lib/test/test_threadsignals.py
+++ b/Lib/test/test_threadsignals.py
@@ -14,7 +14,7 @@ process_pid = os.getpid()
signalled_all=thread.allocate_lock()
-def registerSignals((for_usr1, for_usr2, for_alrm)):
+def registerSignals(for_usr1, for_usr2, for_alrm):
usr1 = signal.signal(signal.SIGUSR1, for_usr1)
usr2 = signal.signal(signal.SIGUSR2, for_usr2)
alrm = signal.signal(signal.SIGALRM, for_alrm)
@@ -74,11 +74,11 @@ def test_main():
signal.SIGUSR2 : {'tripped': 0, 'tripped_by': 0 },
signal.SIGALRM : {'tripped': 0, 'tripped_by': 0 } }
- oldsigs = registerSignals((handle_signals, handle_signals, handle_signals))
+ oldsigs = registerSignals(handle_signals, handle_signals, handle_signals)
try:
run_unittest(ThreadSignals)
finally:
- registerSignals(oldsigs)
+ registerSignals(*oldsigs)
if __name__ == '__main__':
test_main()
diff --git a/Lib/threading.py b/Lib/threading.py
index 439a378..e87a653 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -128,10 +128,9 @@ class _RLock(_Verbose):
# Internal methods used by condition variables
- def _acquire_restore(self, (count, owner)):
+ def _acquire_restore(self, state):
self.__block.acquire()
- self.__count = count
- self.__owner = owner
+ self.__count, self.__owner = state
if __debug__:
self._note("%s._acquire_restore()", self)
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
index 1a72d6f..e94d7b9 100644
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -131,7 +131,8 @@ class TokenError(Exception): pass
class StopTokenizing(Exception): pass
-def printtoken(type, token, (srow, scol), (erow, ecol), line): # for testing
+def printtoken(type, token, startrowcol, endrowcol, line): # for testing
+ (srow, scol), (erow, ecol) = startrowcol, endrowcol
print("%d,%d-%d,%d:\t%s\t%s" % \
(srow, scol, erow, ecol, tok_name[type], repr(token)))
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
index 9c9af45..8cc7a97 100644
--- a/Lib/urlparse.py
+++ b/Lib/urlparse.py
@@ -220,16 +220,18 @@ def urlsplit(url, scheme='', allow_fragments=True):
_parse_cache[key] = v
return v
-def urlunparse((scheme, netloc, url, params, query, fragment)):
+def urlunparse(components):
"""Put a parsed URL back together again. This may result in a
slightly different, but equivalent URL, if the URL that was parsed
originally had redundant delimiters, e.g. a ? with an empty query
(the draft states that these are equivalent)."""
+ scheme, netloc, url, params, query, fragment = components
if params:
url = "%s;%s" % (url, params)
return urlunsplit((scheme, netloc, url, query, fragment))
-def urlunsplit((scheme, netloc, url, query, fragment)):
+def urlunsplit(components):
+ scheme, netloc, url, query, fragment = components
if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'):
if url and url[:1] != '/': url = '/' + url
url = '//' + (netloc or '') + url
diff --git a/Lib/wave.py b/Lib/wave.py
index 81a7141..66d07e5 100644
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -384,7 +384,8 @@ class Wave_write:
def getcompname(self):
return self._compname
- def setparams(self, (nchannels, sampwidth, framerate, nframes, comptype, compname)):
+ def setparams(self, params):
+ nchannels, sampwidth, framerate, nframes, comptype, compname = params
if self._datawritten:
raise Error, 'cannot change parameters after starting to write'
self.setnchannels(nchannels)