berkerpeksag / astor

Python AST read/write
https://pypi.org/project/astor/
BSD 3-Clause "New" or "Revised" License
803 stars 102 forks source link

astor 0.8 - Test failures under Python 3.7.3 #146

Open felixonmars opened 5 years ago

felixonmars commented 5 years ago
root: WARNING:
Files not processed due to syntax errors:
root: WARNING:     /usr/lib/python3.7/lib2to3/tests/data/bom.py
root: WARNING:     /usr/lib/python3.7/lib2to3/tests/data/crlf.py
root: WARNING:     /usr/lib/python3.7/lib2to3/tests/data/different_encoding.py
root: WARNING:     /usr/lib/python3.7/lib2to3/tests/data/false_encoding.py
root: WARNING:     /usr/lib/python3.7/lib2to3/tests/data/py2_test_grammar.py
root: WARNING:     /usr/lib/python3.7/test/bad_coding.py
root: WARNING:     /usr/lib/python3.7/test/bad_coding2.py
root: WARNING:     /usr/lib/python3.7/test/badsyntax_3131.py
root: WARNING:     /usr/lib/python3.7/test/badsyntax_pep3120.py
root: WARNING:
Files failed to round-trip to AST:
root: WARNING:     /usr/lib/python3.7/test/test_fstring.py

Turns out python's fstring test still failed to round trip after the fstring fixes.

felixonmars commented 5 years ago

The generated test_fstring.py became SyntaxError:

  File "test_fstring.py", line 534
    self.assertEqual(f'{"eric\'s"}', "eric's")
                    ^
SyntaxError: f-string expression part cannot include a backslash

The correct source is:

self.assertEqual(f"{'''eric's'''}", "eric's")

Generated srcdmp seems to be correct:

                        Expr(
                            value=Call(func=Attribute(value=Name(id='self'), attr='assertEqual'),
                                args=[
                                    JoinedStr(
                                        values=[FormattedValue(value=Str(s="eric's"), conversion=-1, format_spec=None)]),
                                    Str(s="eric's")],
                                keywords=[])),
berkerpeksag commented 5 years ago

Thanks for the report. This looks like the same case as reported at https://bugs.python.org/issue28002#msg341512.