Fix string parsing with newline (#123)
When looping over a joined str, if a node is ast.Str and the value is just a newline "\n", the write() function adds an additional indentation after it, which fails to represent the original string. By calling self.result.append() here directly the issue is resolved. The added test could show the issue. With code_gen unmodifed, it fails with the following error: ``` AssertionError: "if 1:\n x = f'{host}\\n\\t{port}\\n '" != "if 1:\n x = f'{host}\\n\\t{port}\\n'" if 1: - x = f'{host}\n\t{port}\n '? ---- + x = f'{host}\n\t{port}\n' ``` Which is exactly the problem. This fixes parsing issues with many of Python 3.7's stdlib. Namely the following ones: /usr/lib/python3.7/warnings.py /usr/lib/python3.7/netrc.py /usr/lib/python3.7/test/test_embed.py /usr/lib/python3.7/test/support/testresult.py /usr/lib/python3.7/idlelib/grep.py Fixes #119
Showing
Please
register
or
sign in
to comment