| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…t entire input
The backslash check in the string literal lexer was searching the entire
input expression instead of only the current string value. This caused
false rejections when an identifier containing a backslash appeared in the
same expression as a string literal.
Changed input.find("\\") to value.find("\\") and adjusted the column
offset from backslash_pos + 1 to pos + backslash_pos + 1 so the error
points to the correct position when a backslash is inside a string.
Closes pytest-dev#14474
The test_backslash_in_identifier_with_string_literal test was failing because the matcher function only recognized '\nfoo\n' as a valid identifier. When the expression contained 'mark(x="y")', the matcher returned False for 'mark', causing the entire 'and' expression to evaluate to False instead of True.
There was a problem hiding this comment.
Look good, thanks!
Sorry, something went wrong.
Backport to 9.0.x: 💚 backport PR created✅ Backport PR branch: patchback/backports/9.0.x/984cabfaccf8aa69fe49097ed3d07bd60d05f240/pr-14475 Backported as #14478 🤖 @patchback |
Sorry, something went wrong.
…84cabfaccf8aa69fe49097ed3d07bd60d05f240/pr-14475 [PR #14475/984cabfa backport][9.0.x] fix mark expression scanner: search for backslash in string value, not entire input
| Back | FazBrowse Home | New Git URL |
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:
Added a regression test for the case where backslashes in identifiers coexist with string literals in the same expression.
Closes #14474