Merged revisions 55328-55341 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
........
r55329 | brett.cannon | 2007-05-14 16:36:56 -0700 (Mon, 14 May 2007) | 3 lines
Implement the removal of tuple parameter unpacking (PEP 3113).
Thanks, Tony Lownds for the patch.
........
r55331 | neal.norwitz | 2007-05-14 16:40:30 -0700 (Mon, 14 May 2007) | 1 line
Update to use Python 3.0
........
r55332 | brett.cannon | 2007-05-14 16:47:18 -0700 (Mon, 14 May 2007) | 2 lines
Mention PEP 3113. And thanks to Tony Lownds for the PEP 3113 patch.
........
r55333 | neal.norwitz | 2007-05-14 16:57:06 -0700 (Mon, 14 May 2007) | 1 line
Fix exception printing (no more exceptions module)
........
r55334 | neal.norwitz | 2007-05-14 17:11:10 -0700 (Mon, 14 May 2007) | 1 line
Remove popen* functions from os
........
r55335 | neal.norwitz | 2007-05-14 18:03:38 -0700 (Mon, 14 May 2007) | 1 line
Get rid of most of popen. There are still some uses I need to cleanup.
........
r55336 | neal.norwitz | 2007-05-14 21:11:34 -0700 (Mon, 14 May 2007) | 1 line
Remove a few more remnants of the compiler package
........
r55337 | neal.norwitz | 2007-05-14 22:28:27 -0700 (Mon, 14 May 2007) | 1 line
Get test_[cx]pickle working on 64-bit platforms (avoid overflow int/long)
........
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 @@
# 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 @@
# 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 @@
test_ossaudiodev
test_poll
test_popen
- test_popen2
test_posix
test_pty
test_pwd
@@ -986,7 +985,6 @@
test_ntpath
test_openpty
test_poll
- test_popen2
test_pty
test_pwd
test_strop
@@ -1062,7 +1060,6 @@
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 @@
"the gopherlib module is deprecated",
DeprecationWarning,
"<string>")
-warnings.filterwarnings("ignore", ".*popen2 module is deprecated.*",
- DeprecationWarning)
class AllTest(unittest.TestCase):
@@ -112,7 +110,6 @@
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 @@
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 @@
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 @@
### 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
# 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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()