summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_parser.py')
-rw-r--r--Lib/test/test_parser.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 3bebe7e..054d6d2 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -450,11 +450,29 @@ class CompileTestCase(unittest.TestCase):
st = parser.suite('a = "\\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):
+ # XXX used to be 99 levels in 2.x
+ e = self._nested_expression(93)
+ 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,
)