Seems like compile() can't properly handle assignment expressions parsed in AST object.
Python 3.8.0a2+ (heads/master:06e1e68, Mar 17 2019, 14:27:19)
[Clang 10.0.0 (clang-1000.10.44.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> compile("if a == 1:\n True", '<string>', 'exec')
<code object <module> at 0x10a59ef60, file "<string>", line 1>
>>> compile(ast.parse("if a == 1:\n True"), '<string>', 'exec')
<code object <module> at 0x10a5f6780, file "<string>", line 1>
>>> compile("if a := 1:\n True", '<string>', 'exec')
<code object <module> at 0x10a59ef60, file "<string>", line 1>
>>> compile(ast.parse("if a := 1:\n True"), '<string>', 'exec')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: unexpected expression
>>>
This issue seems to break IPython when trying to use any assignment expressions.
https://github.com/ipython/ipython/issues/11618 |