]> granicus.if.org Git - python/commitdiff
only clear the parser error if it's set (closes #12264)
authorBenjamin Peterson <benjamin@python.org>
Sun, 5 Jun 2011 03:06:42 +0000 (22:06 -0500)
committerBenjamin Peterson <benjamin@python.org>
Sun, 5 Jun 2011 03:06:42 +0000 (22:06 -0500)
Lib/test/test_parser.py
Modules/parsermodule.c

index 020acd500fe2b73f8628037403997c7f4f395469..2b50fca818a042c9fa55b82033ee04225e7eb569 100644 (file)
@@ -614,6 +614,13 @@ class STObjectTestCase(unittest.TestCase):
 
     # 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 @@ def test_main():
         CompileTestCase,
         ParserStackLimitTestCase,
         STObjectTestCase,
+        OtherParserCase,
     )
 
 
index e5b4e559431ba05a91b51444f2ab0d1ed96942ed..1ffa8963ff72bf2ea9a5c52e9fd2d889eeeeb0f7 100644 (file)
@@ -581,10 +581,11 @@ parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type)
             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);
 }