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

Fix regexp string quoting #13236

Merged
merged 1 commit into from Mar 31, 2024
Merged

Fix regexp string quoting #13236

merged 1 commit into from Mar 31, 2024

Conversation

dov
Copy link
Contributor

@dov dov commented Mar 30, 2024

Fix regexp string quoting that cause warnings during cmake

@wwmayer
Copy link
Contributor

wwmayer commented Mar 31, 2024

Which warnings do you get?

@dov
Copy link
Contributor Author

dov commented Mar 31, 2024

Here's the error during cmake:

[1/1505] Generating version_check
/space3/pub-repos/FreeCAD/src/Tools/SubWCRev.py:269: SyntaxWarning: invalid escape sequence '\.'
  match = re.match("git@github\.com:(\S+?)/(\S+\.git)", url) or re.match(
/space3/pub-repos/FreeCAD/src/Tools/SubWCRev.py:270: SyntaxWarning: invalid escape sequence '\.'
  "https://github\.com/(\S+)/(\S+\.git)", url
/space3/pub-repos/FreeCAD/src/Tools/SubWCRev.py:274: SyntaxWarning: invalid escape sequence '\S'
  match = re.match("ssh://\S+?@(\S+)", url)
/space3/pub-repos/FreeCAD/src/Tools/SubWCRev.py:372: SyntaxWarning: invalid escape sequence '\*'
  if re.match("\*", self.branch) is not None:
git
/space3/pub-repos/FreeCAD/build/src/Build/Version.h.out written

It's a simple raw string python error. You can reproduce it by doing:

python
>>> '\s+'   # This is an error
<stdin>:1: SyntaxWarning: invalid escape sequence '\s'
'\\s+'
>>> r'\s+'   # This is ok!
'\\s+'

See e.g.: https://realpython.com/python-raw-strings/

@wwmayer
Copy link
Contributor

wwmayer commented Mar 31, 2024

Thanks. It seems it 's deprecated since Py3.11 or 3.12 because with Py3.10 I don't get this warning.

@wwmayer wwmayer merged commit 67ac363 into FreeCAD:main Mar 31, 2024
10 checks passed
@dov
Copy link
Contributor Author

dov commented Mar 31, 2024

@wwmayer

It's actually always been invalid code. How else would you distinguish between '\n' and '\n' if the former was written? However the warnings indeed to be new. See:

https://adamj.eu/tech/2022/11/04/why-does-python-deprecationwarning-invalid-escape-sequence/

In an case, thanks for merging! Perhaps it will prompt me to submit something more substantial one day.

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.

None yet

2 participants