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

SyntaxWarning on three regular expressions #251

Open
ndhaller opened this issue Jun 19, 2024 · 0 comments
Open

SyntaxWarning on three regular expressions #251

ndhaller opened this issue Jun 19, 2024 · 0 comments

Comments

@ndhaller
Copy link
Contributor

The first time running edkrepo with Python 3.12.4 produces three SyntaxWarning messages.

C:\Tianocore\edk2-edkrepo\edkrepo\common\workspace_maintenance\git_config_maintenance.py:25: SyntaxWarning: invalid escape sequence '\('
  includeif_regex = re.compile('^includeIf "gitdir:%\(prefix\)(/.+)/"$')
C:\Tianocore\edk2-edkrepo\edkrepo\common\workspace_maintenance\git_config_maintenance.py:28: SyntaxWarning: invalid escape sequence '\('
  includeif_regex_old = re.compile('^includeIf "gitdir:%\(prefix\)(/.+)/"$')
C:\Tianocore\edk2-edkrepo\edkrepo\commands\sync_command.py:517: SyntaxWarning: invalid escape sequence '\('
  includeif_regex = re.compile('^includeIf "gitdir:{}(/.+)/"$'.format('%\(prefix\)' if prefix_required else ''))

Clearing the __pycache__ folders and running again produces the SyntaxWarning again.

SyntaxWarning messages not reproducible with Python 3.11.9.

https://docs.python.org/3/whatsnew/3.12.html

A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+\.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw strings for regular expression: re.compile(r"\d+\.\d+")). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning.
ndhaller added a commit to ndhaller/edk2-edkrepo that referenced this issue Jun 19, 2024
To resolve "SyntaxWarning: invalid escape sequence '\('" with Python 3.12.4.
tianocore#251

Signed-off-by: Nathaniel Haller <[email protected]>
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

1 participant