summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFacundo Batista <facundobatista@gmail.com>2008-02-23 12:01:13 (GMT)
committerFacundo Batista <facundobatista@gmail.com>2008-02-23 12:01:13 (GMT)
commitfc2d01032fa4eb2d5563c2619811d05567faf528 (patch)
tree735d908f0418bacf869c516b8deb6b545f5cacba /Lib
parent7832d4d534ff7105a0253694db734d5007b62e91 (diff)
downloadcpython-fc2d01032fa4eb2d5563c2619811d05567faf528.zip
cpython-fc2d01032fa4eb2d5563c2619811d05567faf528.tar.gz
cpython-fc2d01032fa4eb2d5563c2619811d05567faf528.tar.bz2
Issue 1881. Increased the stack limit from 500 to 1500. Also added
a test for this (and because of this test you'll see in stderr a message that parser.c sends before raising MemoryError). Thanks Ralf Schmitt.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_parser.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index fd28610..4119112 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -480,11 +480,28 @@ class CompileTestCase(unittest.TestCase):
st = parser.suite('a = u"\u1"')
self.assertRaises(SyntaxError, parser.compilest, st)
+class ParserStackLimitTestCase(unittest.TestCase):
+ """try to push the parser to/over it's limits.
+ see http://bugs.python.org/issue1881 for a discussion
+ """
+ def _nested_expression(self, level):
+ return "["*level+"]"*level
+
+ def test_deeply_nested_list(self):
+ e = self._nested_expression(99)
+ st = parser.expr(e)
+ st.compile()
+
+ def test_trigger_memory_error(self):
+ e = self._nested_expression(100)
+ self.assertRaises(MemoryError, parser.expr, e)
+
def test_main():
test_support.run_unittest(
RoundtripLegalSyntaxTestCase,
IllegalSyntaxTestCase,
CompileTestCase,
+ ParserStackLimitTestCase,
)