mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Issue #18896: Python function can now have more than 255 parameters.
collections.namedtuple() now supports tuples with more than 255 elements.
This commit is contained in:
parent
14d8b9693b
commit
5bb8b9134b
10 changed files with 33 additions and 49 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue