Skip to content

incorrect escaped string unparse #58

Description

@scgbckbone

create a file with following contents and name it target.py:

phys_vol_name = "test123"
raise RuntimeError(f'Can\'t find the volume group "{phys_vol_name}"')

then use this script to parse & unparse to create new file result.py

import ast
import astunparse

with open("target.py", "r") as f:
    res = astunparse.unparse(ast.parse(f.read()))

with open("result.py", "w") as ff:
    ff.write(res)

when you run result.py you get syntaxt error:

File "result.py", line 3
    raise RuntimeError(f"""Can't find the volume group "{phys_vol_name}"""")
                                                                           ^
SyntaxError: EOL while scanning string literal

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions