Index: Python/pythonrun.c =================================================================== --- Python/pythonrun.c (Revision 88649) +++ Python/pythonrun.c (Arbeitskopie) @@ -2052,6 +2052,9 @@ case E_IDENTIFIER: msg = "invalid character in identifier"; break; + case E_TOONESTED: + PyErr_SetString(PyExc_MemoryError, "too many opening parens"); + goto cleanup; default: fprintf(stderr, "error=%d\n", err->error); msg = "unknown parsing error"; Index: Include/errcode.h =================================================================== --- Include/errcode.h (Revision 88649) +++ Include/errcode.h (Arbeitskopie) @@ -30,6 +30,7 @@ #define E_EOLS 24 /* EOL in single-quoted string */ #define E_LINECONT 25 /* Unexpected characters after a line continuation */ #define E_IDENTIFIER 26 /* Invalid characters in identifier */ +#define E_TOONESTED 27 /* Too many opening parens */ #ifdef __cplusplus } Index: Parser/parser.c =================================================================== --- Parser/parser.c (Revision 88649) +++ Parser/parser.c (Arbeitskopie) @@ -39,8 +39,7 @@ { register stackentry *top; if (s->s_top == s->s_base) { - fprintf(stderr, "s_push: parser stack overflow\n"); - return E_NOMEM; + return E_TOONESTED; } top = --s->s_top; top->s_dfa = d; Index: Lib/test/test_parser.py =================================================================== --- Lib/test/test_parser.py (Revision 88649) +++ Lib/test/test_parser.py (Arbeitskopie) @@ -542,9 +542,6 @@ def test_trigger_memory_error(self): e = self._nested_expression(100) - print("Expecting 's_push: parser stack overflow' in next line", - file=sys.stderr) - sys.stderr.flush() self.assertRaises(MemoryError, parser.expr, e) class STObjectTestCase(unittest.TestCase):