-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Repro:
Python 3.9.2 (default, Mar 3 2021, 20:02:32)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import astunparse
>>> import ast
>>> n = ast.parse('return foo(x)[:, tf.newaxis] - foo(x)[tf.newaxis, :]')
>>> astunparse.unparse(n)
'\nreturn (foo(x)[(:, tf.newaxis)] - foo(x)[(tf.newaxis, :)])\n'
>>> ast.parse(_)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/mdan/miniconda3/envs/py39test/lib/python3.9/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "<unknown>", line 2
return (foo(x)[(:, tf.newaxis)] - foo(x)[(tf.newaxis, :)])
^
SyntaxError: invalid syntax
>>>
It seems that the extra parens inserted around the slice are at fault. They do not appear in Python 3.7.
Metadata
Metadata
Assignees
Labels
No labels