-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Literal raw string/bytes backslashes are highlighted as escapes #13702
Comments
I was not sure if I posted this bug in the right place, so I dug around a little to try to find the token/grammar specification in this repo. I couldn't find anything. Maybe this comes from TextMate, the grammar provider for VSCode? Also, to provide a little more context, I found a nifty command that brings up a tooltip about the tokenization that occurred at the current position in a document: Perhaps this file https://github.com/textmate/python.tmbundle/blob/master/Syntaxes/Python.tmLanguage. This file defines the scopes/tokens with the same names as those in the tooltip above, which adds confidence that this is the right file. Also, I did see some specific handling for raw literals in there. However, these files are complex and I'm not sure how they work. |
We don't control syntax highlighting for Python files. That comes from VS Code which gets it from MagicPython. It's best to report an issue there. |
Thanks for pointing me in the right direction @brettcannon. For posterity, one can workaround to the expected behavior by using capitalized "R"s in front of the literals (even though this distinction is not part of the Python grammar). More info here: MagicStack/MagicPython#114 |
Environment data
v2020.8.105369
Windows 10
Python 3.8.5
virtualenv
stdlib packagePython 3.8.5
v2020.8.105369
python.languageServer
setting:v2020.8.105369
Pylance language server 2020.8.3 (pyright 8c5415fd)
(Sorry, unsure how to query this value, so previous values are just copy-pastes from extension page and Python Language Server output log.)Expected behaviour
Backslashes (and the characters that follow them) in raw string literals and raw byte literals should not be highlighted. Highlighting in this case should be reserved for non-raw literals, where the backslashes create an escaped character.
from https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
Actual behaviour
Backslashes are highlighted in these cases as if they are escape characters, which they are not.
Steps to reproduce:
The text was updated successfully, but these errors were encountered: