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 3.11 complains about invalid escape sequence in test-suite/tools/parsers/parse_wpout.py #507

Closed
merkys opened this issue Jul 1, 2024 · 5 comments
Milestone

Comments

@merkys
Copy link

merkys commented Jul 1, 2024

Multiple SyntaxWarnings are thrown from test-suite/tools/parsers/parse_wpout.py when running tests with Python 3.11, for example:

test-suite/tools/parsers/parse_wpout.py:16:
SyntaxWarning: invalid escape sequence '\s'
near_neigh_re = re.compile("^\s*\|\s+(\d+)\s+([\d\.]+)\s*(\d+)\s*")
@jryates jryates added this to the v4.0 milestone Jan 11, 2025
@jryates
Copy link
Member

jryates commented Jan 11, 2025

I have seen this issue before. I think the issue is using back-slashes for something that isn't an escape sequence. In older version of python this generated a depreciation note, but in newer versions it gives a Syntax warning. One fix is to pass a raw string - e.g. change
wildcards = re.compile('.*(\*|\?|\[.*\]).*')
to
wildcards = re.compile(r'.*(\*|\?|\[.*\]).*')
I'm not very confident with python, so I'll consult before proposing a PR.

@merkys
Copy link
Author

merkys commented Jan 13, 2025

@jryates did you mean adding r before the opening single quote (both your code lines are identical)? I have seen this suggestion in many other places and it seems to work.

@jryates
Copy link
Member

jryates commented Jan 13, 2025

@merkys - I did. The current script does not have the r. I have corrected my earlier comment.

@jryates
Copy link
Member

jryates commented Jan 15, 2025

Fixed by #531

@jryates jryates closed this as completed Jan 15, 2025
@merkys
Copy link
Author

merkys commented Jan 16, 2025

Thanks for fixing this!

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

No branches or pull requests

2 participants