-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Python 3.12 tokenize generates invalid locations for f'\N{unicode}' #115154
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
Comments
cc @pablogsal |
The tokens parsing
The problem is that when Untokenizer.untokenize, line215 sees the FSTRING_MIDDLE token, it replaces '{' and '}' with '{{' and '}}' and bumps the end position by 2, making the end column 2 more than the next start column. This works when the presence of curly brackets results from the reverse process, but not when the lexer recognizes \N{name} as a unicode named literal without replacing it with the indicated character. Other escapes are resolved, as with '\ueeee' being tokenized as a single character. Unless the tokenizer replaces \N{name} with a character, the untokenizer must recognize it also and not do the replacement. |
CC: @isidentical |
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
…ythonGH-115171) (cherry picked from commit ecf16ee) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Bug report
Bug description:
ValueError: start (1,22) precedes previous end (1,24)
CPython versions tested on:
3.12
Operating systems tested on:
Windows
Linked PRs
The text was updated successfully, but these errors were encountered: