• Felix Yan's avatar
    Fix string parsing with newline (#123) · c72349f3
    Felix Yan yazdı
    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
    c72349f3
Adı
Son kayıt (commit)
Son güncelleme
astor Loading commit data...
docs Loading commit data...
tests Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
AUTHORS Loading commit data...
LICENSE Loading commit data...
MANIFEST.in Loading commit data...
Makefile Loading commit data...
README.rst Loading commit data...
requirements-dev.txt Loading commit data...
requirements-tox.txt Loading commit data...
setup.cfg Loading commit data...
setup.py Loading commit data...
setuputils.py Loading commit data...
tox.ini Loading commit data...