astunparse
astunparse copied to clipboard
Skipped test for Python 3.6 is valid code
This test fails (if you unskip it) for Python 3.6 and 3.7 (but works for Python 3.8, presumably because of ast.Constant changes?)
@unittest.skipUnless(sys.version_info < (3, 6), "Only works for Python < 3.6")
def test_integer_parens(self):
self.check_roundtrip("3 .__abs__()")
The issue is astunparse doesn't add back in the necessary space:
Python 3.6.10 (default, Jan 23 2020, 23:35:52)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 3 .__abs__()
3
>>> 3.__abs__()
File "<stdin>", line 1
3.__abs__()
^
SyntaxError: invalid syntax
>>> import ast
>>> import astunparse
>>> astunparse.unparse(ast.parse("3 .__abs__()"))
'\n3.__abs__()\n'