New submission from Bogdan Opanchuk <[email protected]>:
Tested in PyPy 2.2.1
The following code:
import ast
tree = ast.parse("a = None")
print(ast.dump(tree))
compile(tree, '<nofile>', 'exec')
print(ast.dump(tree))
produced the following output:
Module(body=[Assign(targets=[Name(id='a', ctx=Store())],
value=Name(id='None', ctx=Load()))])
Module(body=[Assign(targets=[Name(id='a', ctx=Store())],
value=Const(value=None))])
Apparently, compile() mutated the `tree` argument (adding the `Const` node which
is, incidentally, not even present in
http://docs.python.org/2/library/ast.html#abstract-grammar). The same code in
CPython 2.7.6 or 3.4.0 does not change `tree`. The documentation for `compile()`
does not indicate that the `tree` argument may be changed.
----------
messages: 6682
nosy: bogdan, pypy-issue
priority: bug
release: 2.2
status: unread
title: compile() mutates its argument
________________________________________
PyPy bug tracker <[email protected]>
<https://bugs.pypy.org/issue1728>
________________________________________
_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue