Skip to content

[PR #14475/984cabfa backport][9.0.x] fix mark expression scanner: search for backslash in string value, not entire input#14478

Merged
bluetech merged 1 commit into
9.0.xfrom
patchback/backports/9.0.x/984cabfaccf8aa69fe49097ed3d07bd60d05f240/pr-14475
May 14, 2026
Merged

[PR #14475/984cabfa backport][9.0.x] fix mark expression scanner: search for backslash in string value, not entire input#14478
bluetech merged 1 commit into
9.0.xfrom
patchback/backports/9.0.x/984cabfaccf8aa69fe49097ed3d07bd60d05f240/pr-14475

Conversation

@patchback
Copy link
Copy Markdown

@patchback patchback Bot commented May 13, 2026

This is a backport of PR #14475 as merged into main (984cabf).

The backslash check in the string literal lexer was searching the entire input expression (input.find("\")) instead of only the current string value (value.find("\")). This caused false rejections when an identifier containing a backslash appeared in the same expression as a string literal.

For example, pytest -k 'test\nfoo\n and mark(x="y")' would fail with "escaping not supported" even though the backslash is in the identifier, not the string.

The fix:

  • Changed input.find("\") to value.find("\") so we only check for backslashes inside the string literal
  • Adjusted the column offset from backslash_pos + 1 to pos + backslash_pos + 1 so error positions point to the right place

Added a regression test for the case where backslashes in identifiers coexist with string literals in the same expression.

Closes #14474

…not entire input (#14475)

The backslash check in the string literal lexer was searching the entire
input expression (input.find("\")) instead of only the current string value
(value.find("\")). This caused false rejections when an identifier containing
a backslash appeared in the same expression as a string literal.

For example, `pytest -k 'test\nfoo\n and mark(x="y")'` would fail with
"escaping not supported" even though the backslash is in the identifier,
not the string.

Closes #14474

(cherry picked from commit 984cabf)
@bluetech bluetech merged commit c1108ac into 9.0.x May 14, 2026
33 checks passed
@bluetech bluetech deleted the patchback/backports/9.0.x/984cabfaccf8aa69fe49097ed3d07bd60d05f240/pr-14475 branch May 14, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants