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 lexer broken for raw strings in v3.18.0 #1507

Closed
tuxu opened this issue Apr 24, 2020 · 3 comments · Fixed by #1508
Closed

Python lexer broken for raw strings in v3.18.0 #1507

tuxu opened this issue Apr 24, 2020 · 3 comments · Fixed by #1508
Assignees
Labels
bugfix-request A request for a bugfix to be developed.

Comments

@tuxu
Copy link

tuxu commented Apr 24, 2020

Name of the lexer
Python

Code sample

The two below examples show that escaped characters in raw strings confuse the lexer.

import re
s = "Hello World"
m = re.findall(r"^[\w]+", s)
print(m)

(rouge.jneen.net)

devid_line = status_line.split('STATUS:')[0]
result_line = status_line.split('STATUS:')[1]
print(f'Parsing "{result_line}"...')

# parse devid string
pattern = re.compile(r'.*\[p00t_(d\d{4})\].*')
data = pattern.match(devid_line)
devid = data.group(1)

(rouge.jneen.net)

Additional context

There is an issue in the GitLab issue tracker which describes the same problem:
https://gitlab.com/gitlab-org/gitlab/-/issues/215643

I traced the problem back to commit 652a622: Use generic string states in Python lexer (#1477)

@tuxu tuxu added the bugfix-request A request for a bugfix to be developed. label Apr 24, 2020
@pyrmont pyrmont self-assigned this Apr 24, 2020
@pyrmont
Copy link
Contributor

pyrmont commented Apr 24, 2020

@tuxu Thanks for the detailed report and sorry for the trouble :( Will have a look at that now.

@Spindel
Copy link

Spindel commented Apr 29, 2020

It's not only raw strings, this also seems to set it off:

var = "\w+"
foo = "bar"

@pyrmont
Copy link
Contributor

pyrmont commented Apr 29, 2020

@Spindel Thanks for the report! The code in the PR will fix this too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix-request A request for a bugfix to be developed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants