Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native parser crashes on rf"\\" #917

Closed
Zac-HD opened this issue Apr 28, 2023 · 0 comments · Fixed by #921
Closed

Native parser crashes on rf"\\" #917

Zac-HD opened this issue Apr 28, 2023 · 0 comments · Fixed by #921
Labels
bug Something isn't working parsing Converting source code into CST nodes

Comments

@Zac-HD
Copy link
Contributor

Zac-HD commented Apr 28, 2023

import contextlib, os
from libcst import parse_expression

@contextlib.contextmanager
def native_parser():
    var = os.environ.get("LIBCST_PARSER_TYPE")
    try:
        os.environ["LIBCST_PARSER_TYPE"] = "native"
        yield
    finally:
        os.environ.pop("LIBCST_PARSER_TYPE")
        if var is not None:
            os.environ["LIBCST_PARSER_TYPE"] = var

string_literal = r'rf"\\"'
parse_expression(string_literal)  # fine :-)
with native_parser():
    parse_expression(string_literal)  # fails :-(
@zsol zsol added bug Something isn't working parsing Converting source code into CST nodes labels May 17, 2023
@zsol zsol closed this as completed in #921 May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parsing Converting source code into CST nodes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants