GNOME Bugzilla – Bug 659113
AST pattern for with statements does not match in Python 2.6
Last modified: 2011-09-17 17:38:51 UTC
It appears that the AST for with statements changed between Python 2.6 and 2.7. The existing code is written for 2.7 (I believe) and doesn't work on 2.6. This adds patterns for 2.6 and switches between them based on the existance of symbol.with_item. I tried not to mess anything up for 2.7, but I don't have things set up to test that.
Created attachment 196576 [details] [review] Add compatibility for Python 2.6 AST for with statement. Python 2.6 has a slightly different AST for with statments than Python 2.7 does. We choose the relevant AST pattern py testing for the existance of symbol.with_item, which exists in 2.7 but not in 2.6.
This was fixed in a different way by: commit ce2dfcc6eeac01384b0b2156a52c42d5d29aced1 Author: Owen W. Taylor <otaylor@fishsoup.net> Date: Fri Sep 16 13:18:03 2011 -0400 rewrite.py: Rewrite to use the AST rather tha the parse tree In Python-2.5, the 'ast' module was introduced that is remarkably easier to use than the 'parser' module, since we're working in terms of the logical syntax of Python rather than the detailed grammar. Rewrite rewrite.py to use this instead, removing a lot of code and simplifying maintenance.