diff options
author | Guido van Rossum <guido@python.org> | 2007-02-26 21:23:50 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-02-26 21:23:50 (GMT) |
commit | 0240b92a6c3a17fac38d93ee80fc8e8523388786 (patch) | |
tree | 8434f85d5b00ca30cc2fad24082ba454a43a4409 /Lib/test/test_compile.py | |
parent | f74225d63b84a4d3b508fd5657cfe2596633876a (diff) | |
download | cpython-0240b92a6c3a17fac38d93ee80fc8e8523388786.zip cpython-0240b92a6c3a17fac38d93ee80fc8e8523388786.tar.gz cpython-0240b92a6c3a17fac38d93ee80fc8e8523388786.tar.bz2 |
Two more patches by Tony Lownds (SF# 1607548).
(1)
Combines the code paths for MAKE_FUNCTION and MAKE_CLOSURE.
Fixes a crash where functions with closures and either annotations or
keyword-only arguments result in MAKE_CLOSURE, but only
MAKE_FUNCTION has the code to handle annotations or keyword-only
arguments.
Includes enough tests to trigger the bug.
(2)
Change peepholer to not bail in the presence of EXTENDED_ARG +
MAKE_FUNCTION.
Enforce the natural 16-bit limit of annotations in compile.c.
Also update Misc/NEWS with the "input = raw_input" change.
Diffstat (limited to 'Lib/test/test_compile.py')
-rw-r--r-- | Lib/test/test_compile.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 022f7c0..d5fda13 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -393,6 +393,19 @@ if 1: del d[..., ...] 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 + # 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 xrange(65535)) + 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 xrange(65534)) + compile(s, '?', 'exec') + def test_main(): test_support.run_unittest(TestSpecifics) |