Patches item #1642547, was opened at 2007-01-23 09:02 Message generated for change (Comment added) made by collinwinter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1642547&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Core (C code) Group: None Status: Closed Resolution: Accepted Priority: 9 Private: No Submitted By: Thomas Wouters (twouters) Assigned to: Thomas Wouters (twouters) Summary: Fix error/crash in AST: syntaxerror in complex ifs Initial Comment: Fix a bug in Python/ast.c, where a particular syntaxerror in an 'if' with one or more 'elif's would be ignored or mishandled: timberwolf:~/python/python/trunk > cat test2.py def bug(): if w: dir()=1 elif v: pass timberwolf:~/python/python/trunk > python2.4 test2.py File "test2.py", line 3 dir()=1 SyntaxError: can't assign to function call timberwolf:~/python/python/trunk > python2.5 test2.py Exception exceptions.SyntaxError: ("can't assign to function call", 3) in 'garbage collection' ignored Fatal Python error: unexpected exception during garbage collection Aborted The actual problem is the lack of error checks on the return values of ast_for_expr() and ast_for_suite, in ast_for_if_stmt. Attached patch fixes. ---------------------------------------------------------------------- >Comment By: Collin Winter (collinwinter) Date: 2007-03-16 00:20 Message: Logged In: YES user_id=1344176 Originator: NO PEP 7's section on Py3k says 4-space indents, no tabs. ---------------------------------------------------------------------- Comment By: Neal Norwitz (nnorwitz) Date: 2007-03-16 00:16 Message: Logged In: YES user_id=33168 Originator: NO It would be great to clean up the indentation in ast.c. I think I fixed it (at least made it consistent) in compile.c. Probably symtable.c could use it too. All the files that were new from the AST branch should be cleaned up and use the proper formatting we are using for 3k. I don't remember exactly what it is, but I think it's 4 space indents, but possibly still using tabs. ---------------------------------------------------------------------- Comment By: Collin Winter (collinwinter) Date: 2007-03-16 00:13 Message: Logged In: YES user_id=1344176 Originator: NO Updated to apply against SVN HEAD and incorporated the additional error checking Martin pointed out. Checked in as r54404 (trunk), r54405 (release25-maint). Any objection to cleaning up ast.c's indentation? It's an ungodly mess. ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2007-02-14 04:46 Message: Logged In: YES user_id=21627 Originator: NO The patch looks fine to me, please apply (or let me know if you want me to apply it). I think there are a few other places where return values of ast_for_ aren't checked: - ast_for_listcomp, not checking ast_for_expr results - ast_for_withexpr, not checking context_expr ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1642547&group_id=5470 _______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches