]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Partial backport for changes to fix SF bug #678518 (assert & global).
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 10 Feb 2003 01:57:51 +0000 (01:57 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 10 Feb 2003 01:57:51 +0000 (01:57 +0000)
Lib/test/test_parser.py
Misc/NEWS
Modules/parsermodule.c

index cbe1de6aad66d911fafccefa6db6e40136142fca..d5c7583048f40dfef92aca02973abe54bdaf44ed 100644 (file)
@@ -137,6 +137,9 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
         self.check_suite("import sys as system, math")
         self.check_suite("import sys, math as my_math")
 
+    def test_assert(self):
+        self.check_suite("assert alo < ahi and blo < bhi\n")
+
 #
 #  Second, we take *invalid* trees and make sure we get ParserError
 #  rejections for them.
@@ -357,6 +360,16 @@ class IllegalSyntaxTestCase(unittest.TestCase):
          (0, ''))
         self.check_bad_tree(tree, "a $= b")
 
+    def test_malformed_global(self):
+        #doesn't have global keyword in ast
+        tree = (257,
+                (264,
+                 (265,
+                  (266,
+                   (282, (1, 'foo'))), (4, ''))),
+                (4, ''),
+                (0, '')) 
+        self.check_bad_tree(tree, "malformed global ast")
 
 def test_main():
     loader = unittest.TestLoader()
index 6e6a34014db3ac4de1a181782f42c9af09a69d87..df94add92f1f92283576cd544109160dea7c8735 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -2,6 +2,8 @@ What's New in Python 2.2.3 ?
 Release date: XX-XXX-2003
 ============================
 
+- SF bug #678518:  fix some bugs in the parser module.  
+
 - Bastion.py and rexec.py are disabled.  These modules are not safe in
   Python 2.2. or 2.3.
 
index 20db86e1fe2a221c2beb7f20331eadbd74f45733..945c9231bf575ef5b72d8b4e00d7ad2b08ef7bda 100644 (file)
@@ -1692,6 +1692,9 @@ validate_global_stmt(node *tree)
     int res = (validate_ntype(tree, global_stmt)
                && is_even(nch) && (nch >= 2));
 
+    if (!res && !PyErr_Occurred())
+        err_string("illegal global statement");
+
     if (res)
         res = (validate_name(CHILD(tree, 0), "global")
                && validate_ntype(CHILD(tree, 1), NAME));
@@ -1739,8 +1742,7 @@ validate_assert_stmt(node *tree)
     int nch = NCH(tree);
     int res = (validate_ntype(tree, assert_stmt)
                && ((nch == 2) || (nch == 4))
-               && (validate_name(CHILD(tree, 0), "__assert__") ||
-                   validate_name(CHILD(tree, 0), "assert"))
+               && (validate_name(CHILD(tree, 0), "assert"))
                && validate_test(CHILD(tree, 1)));
 
     if (!res && !PyErr_Occurred())