[Python-checkins] r60974 - in python/trunk: Lib/test/test_parser.py Misc/NEWS Parser/parser.h
facundo.batista
python-checkins at python.org
Sat Feb 23 13:01:14 CET 2008
Author: facundo.batista
Date: Sat Feb 23 13:01:13 2008
New Revision: 60974
Modified:
python/trunk/Lib/test/test_parser.py
python/trunk/Misc/NEWS
python/trunk/Parser/parser.h
Log:
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.
Modified: python/trunk/Lib/test/test_parser.py
==============================================================================
--- python/trunk/Lib/test/test_parser.py (original)
+++ python/trunk/Lib/test/test_parser.py Sat Feb 23 13:01:13 2008
@@ -480,11 +480,28 @@
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,
)
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Sat Feb 23 13:01:13 2008
@@ -12,6 +12,9 @@
Core and builtins
-----------------
+- Issue #1881: An internal parser limit has been increased. Also see
+ issue 215555 for a discussion.
+
- Added the future_builtins module, which contains hex() and oct().
These are the PEP 3127 version of these functions, designed to be
compatible with the hex() and oct() builtins from Python 3.0. They
Modified: python/trunk/Parser/parser.h
==============================================================================
--- python/trunk/Parser/parser.h (original)
+++ python/trunk/Parser/parser.h Sat Feb 23 13:01:13 2008
@@ -7,7 +7,7 @@
/* Parser interface */
-#define MAXSTACK 500
+#define MAXSTACK 1500
typedef struct {
int s_state; /* State in current DFA */
More information about the Python-checkins
mailing list