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

[Python] Fix double quoted u-string scope #3889

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Python/Python.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -3188,7 +3188,7 @@ contexts:

double-quoted-u-string-body:
- meta_include_prototype: false
- meta_content_scope: meta.string.python string.quoted.double.block.python
- meta_content_scope: meta.string.python string.quoted.double.python
- include: double-quoted-string-end
- include: double-quoted-u-string-syntax

Expand Down
13 changes: 13 additions & 0 deletions Python/tests/syntax_test_python_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,30 @@
# ^ keyword.other.DML.sql

conn.execute(U"SELECT * FROM foobar")
# ^ meta.string.python string.quoted.double.python punctuation.definition.string.begin.python
# ^^^^^^^^^^^^^^^^^^^^ meta.string.python source.sql
# ^ meta.string.python string.quoted.double.python punctuation.definition.string.end.python
# ^ keyword.other.DML.sql

conn.execute(U'SELECT * FROM foobar')
# ^ meta.string.python string.quoted.single.python punctuation.definition.string.begin.python
# ^^^^^^^^^^^^^^^^^^^^ meta.string.python source.sql
# ^ meta.string.python string.quoted.single.python punctuation.definition.string.end.python
# ^ keyword.other.DML.sql

# In this example, the Python string is not raw, so \t is a python escape
conn.execute(u"SELECT * FROM foobar WHERE foo = '\t'")
# ^ storage.type.string.python
# ^ meta.string.python string.quoted.double.python punctuation.definition.string.begin.python
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.python source.sql
# ^ keyword.other.DML.sql
# ^ constant.character.escape.python
# ^ meta.string.python string.quoted.double.python punctuation.definition.string.end.python

conn.execute(u'SELECT * FROM foobar')
# ^ meta.string.python string.quoted.single.python punctuation.definition.string.begin.python
# ^^^^^^^^^^^^^^^^^^^^ meta.string.python source.sql
# ^ meta.string.python string.quoted.single.python punctuation.definition.string.end.python
# ^ keyword.other.DML.sql

# In this example, the Python string is raw, so the \b should be a SQL escape
Expand Down