[issue9011] ast_for_factor unary minus optimization changes AST
report at bugs.python.org
Thu Jun 17 11:21:05 CEST 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
Confirmed in trunk and py3k, both of which raise ValueError on the second compile:
Python 2.7rc1+ (trunk:82042, Jun 17 2010, 09:52:12)
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import parser
>>> st = parser.expr("-3")
<code object <module> at 0x450448, file "<syntax-tree>", line 1>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: could not convert string to float: --3
This looks nasty; unless there's some rule that says that you're not supposed to hang on to AST objects after compiling them. (Is there?)
Benjamin, would it be worth just getting rid of this optimization for 2.7, and trying to reinstate a correct version for 2.7.1?
[Removing 2.5 from the versions list since there's nothing we can do about it there (2.5 is only getting security fixes at this point).]
See also issue 1441486.
versions: +Python 2.7, Python 3.2
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list