[Python-checkins] cpython: only clear the parser error if it's set (closes #12264)

benjamin.peterson python-checkins at python.org
Sun Jun 5 05:08:55 CEST 2011


http://hg.python.org/cpython/rev/3ffd8dea77bf
changeset:   70638:3ffd8dea77bf
parent:      70632:ac562d86ab71
user:        Benjamin Peterson <benjamin at python.org>
date:        Sat Jun 04 22:06:42 2011 -0500
summary:
  only clear the parser error if it's set (closes #12264)

files:
  Lib/test/test_parser.py |  8 ++++++++
  Modules/parsermodule.c  |  5 +++--
  2 files changed, 11 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -614,6 +614,13 @@
 
     # XXX tests for pickling and unpickling of ST objects should go here
 
+class OtherParserCase(unittest.TestCase):
+
+    def test_two_args_to_expr(self):
+        # See bug #12264
+        with self.assertRaises(TypeError):
+            parser.expr("a", "b")
+
 
 def test_main():
     support.run_unittest(
@@ -622,6 +629,7 @@
         CompileTestCase,
         ParserStackLimitTestCase,
         STObjectTestCase,
+        OtherParserCase,
     )
 
 
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -581,10 +581,11 @@
             if (res)
                 ((PyST_Object *)res)->st_flags.cf_flags = flags & PyCF_MASK;
         }
-        else
+        else {
             PyParser_SetError(&err);
+            PyParser_ClearError(&err);
+        }
     }
-    PyParser_ClearError(&err);
     return (res);
 }
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list