summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-16 17:19:02 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-16 17:19:02 (GMT)
commit5bb8b9134b0bb35a73c76657f41cafa3e4361fcd (patch)
tree5755343717913be71dc48d94db681d1a21ff31d2 /Lib/test
parent14d8b9693be235240ab2dcac3b43a4a7c30483bc (diff)
downloadcpython-5bb8b9134b0bb35a73c76657f41cafa3e4361fcd.zip
cpython-5bb8b9134b0bb35a73c76657f41cafa3e4361fcd.tar.gz
cpython-5bb8b9134b0bb35a73c76657f41cafa3e4361fcd.tar.bz2
Issue #18896: Python function can now have more than 255 parameters.
collections.namedtuple() now supports tuples with more than 255 elements.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_collections.py3
-rw-r--r--Lib/test/test_compile.py11
-rw-r--r--Lib/test/test_keywordonlyarg.py24
-rw-r--r--Lib/test/test_sys.py2
4 files changed, 10 insertions, 30 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 87454cc..76c7139 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -319,8 +319,7 @@ class TestNamedTuple(unittest.TestCase):
self.assertEqual(Dot(1)._replace(d=999), (999,))
self.assertEqual(Dot(1)._fields, ('d',))
- # n = 5000
- n = 254 # SyntaxError: more than 255 arguments:
+ n = 5000
names = list(set(''.join([choice(string.ascii_letters)
for j in range(10)]) for i in range(n)))
n = len(names)
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 409ec86..4a7230f 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -401,16 +401,9 @@ if 1:
self.assertNotIn((Ellipsis, Ellipsis), d)
def test_annotation_limit(self):
- # 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.
+ # more than 255 annotations, should compile ok
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(255))
+ s %= ', '.join('a%d:%d' % (i,i) for i in range(300))
compile(s, '?', 'exec')
def test_mangling(self):
diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py
index d82e33d..2cf8a89 100644
--- a/Lib/test/test_keywordonlyarg.py
+++ b/Lib/test/test_keywordonlyarg.py
@@ -51,24 +51,12 @@ class KeywordOnlyArgTestCase(unittest.TestCase):
self.assertRaisesSyntaxError("def f(p, *, (k1, k2), **kw):\n pass\n")
def testSyntaxForManyArguments(self):
- fundef = "def f("
- for i in range(255):
- fundef += "i%d, "%i
- fundef += "*, key=100):\n pass\n"
- self.assertRaisesSyntaxError(fundef)
-
- fundef2 = "def foo(i,*,"
- for i in range(255):
- fundef2 += "i%d, "%i
- fundef2 += "lastarg):\n pass\n"
- self.assertRaisesSyntaxError(fundef2)
-
- # exactly 255 arguments, should compile ok
- fundef3 = "def f(i,*,"
- for i in range(253):
- fundef3 += "i%d, "%i
- fundef3 += "lastarg):\n pass\n"
- compile(fundef3, "<test>", "single")
+ # more than 255 positional arguments, should compile ok
+ fundef = "def f(%s):\n pass\n" % ', '.join('i%d' % i for i in range(300))
+ compile(fundef, "<test>", "single")
+ # more than 255 keyword-only arguments, should compile ok
+ fundef = "def f(*, %s):\n pass\n" % ', '.join('i%d' % i for i in range(300))
+ compile(fundef, "<test>", "single")
def testTooManyPositionalErrorMessage(self):
def f(a, b=None, *, c=None):
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 828421c..e6d8e50 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -926,7 +926,7 @@ class SizeofTest(unittest.TestCase):
def inner():
return x
return inner
- check(get_cell2.__code__, size('6i13P') + 1)
+ check(get_cell2.__code__, size('6i13P') + calcsize('n'))
# complex
check(complex(0,1), size('2d'))
# method_descriptor (descriptor object)