[Python-checkins] commit of r41642 - in python/trunk: Lib/test/test_grammar.py Python/ast.c
neal.norwitz
python-checkins at python.org
Sun Dec 11 21:12:41 CET 2005
Author: neal.norwitz
Date: Sun Dec 11 21:12:40 2005
New Revision: 41642
Modified:
python/trunk/Lib/test/test_grammar.py
python/trunk/Python/ast.c
Log:
SF #1377897, Bus error in ast
If a line had multiple semi-colons and ended with a semi-colon, we would
loop too many times and access a NULL node. Exit the loop early if
there are no more children.
Modified: python/trunk/Lib/test/test_grammar.py
==============================================================================
--- python/trunk/Lib/test/test_grammar.py (original)
+++ python/trunk/Lib/test/test_grammar.py Sun Dec 11 21:12:40 2005
@@ -276,6 +276,10 @@
### simple_stmt: small_stmt (';' small_stmt)* [';']
print 'simple_stmt'
x = 1; pass; del x
+def foo():
+ # verify statments that end with semi-colons
+ x = 1; pass; del x;
+foo()
### small_stmt: expr_stmt | print_stmt | pass_stmt | del_stmt | flow_stmt | import_stmt | global_stmt | access_stmt | exec_stmt
# Tested below
Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c (original)
+++ python/trunk/Python/ast.c Sun Dec 11 21:12:40 2005
@@ -2562,6 +2562,11 @@
ch = CHILD(ch, 0);
REQ(ch, simple_stmt);
for (j = 0; j < NCH(ch); j += 2) {
+ /* statement terminates with a semi-colon ';' */
+ if (NCH(CHILD(ch, j)) == 0) {
+ assert((j + 1) == NCH(ch));
+ break;
+ }
s = ast_for_stmt(c, CHILD(ch, j));
if (!s)
goto error;
More information about the Python-checkins
mailing list