[Patches] [ python-Patches-1642547 ] Fix error/crash in AST: syntaxerror in complex ifs

SourceForge.net noreply at sourceforge.net
Wed Feb 14 10:46:46 CET 2007


Patches item #1642547, was opened at 2007-01-23 15:02
Message generated for change (Comment added) made by loewis
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: Open
>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: Martin v. Löwis (loewis)
Date: 2007-02-14 10: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


More information about the Patches mailing list