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

Parse error for unicode character name literals in f-strings #400

Closed
zsol opened this issue Oct 8, 2020 · 2 comments
Closed

Parse error for unicode character name literals in f-strings #400

zsol opened this issue Oct 8, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@zsol
Copy link
Member

zsol commented Oct 8, 2020

>>> print(f"\N{greek capital letter delta}t")
Δt

but with libcst:

❯ libcst print - 
print(f"\N{greek capital letter delta}t")
Traceback (most recent call last):
  File "/opt/instagram/virtualenv/lib/python3.7/site-packages/fbcode/libcst/_parser/base_parser.py", line 152, in _add_token
    plan = stack[-1].dfa.transitions[transition]
KeyError: TokenType(NAME)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/instagram/virtualenv/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/instagram/virtualenv/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/instagram/virtualenv/lib/python3.7/site-packages/fbcode/libcst/tool.py", line 832, in <module>
    main(os.environ.get("LIBCST_TOOL_COMMAND_NAME", "libcst.tool"), sys.argv[1:])
  File "/opt/instagram/virtualenv/lib/python3.7/site-packages/fbcode/libcst/tool.py", line 827, in main
    return lookup.get(args.action or None, _invalid_command)(proc_name, command_args)
  File "/opt/instagram/virtualenv/lib/python3.7/site-packages/fbcode/libcst/tool.py", line 277, in _print_tree_impl
    else PartialParserConfig()
  File "/opt/instagram/virtualenv/lib/python3.7/site-packages/fbcode/libcst/_parser/entrypoints.py", line 76, in parse_module
    detect_default_newline=True,
  File "/opt/instagram/virtualenv/lib/python3.7/site-packages/fbcode/libcst/_parser/entrypoints.py", line 51, in _parse
    result = parser.parse()
  File "/opt/instagram/virtualenv/lib/python3.7/site-packages/fbcode/libcst/_parser/base_parser.py", line 111, in parse
    self._add_token(token)
  File "/opt/instagram/virtualenv/lib/python3.7/site-packages/fbcode/libcst/_parser/base_parser.py", line 191, in _add_token
    raw_column=token.start_pos[1],
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:18.
Incomplete input. Encountered 'capital', but expected '!', ':', or '}'.

print(f"\N{greek capital letter delta}t")
                 ^
@zsol zsol added the bug Something isn't working label Oct 8, 2020
@zsol
Copy link
Member Author

zsol commented Nov 20, 2020

See also davidhalter/parso#154

@jimmylai
Copy link
Contributor

This issues is fixed by davidhalter/parso#160 and will be available in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants