tianocore / edk2-edkrepo

Repository for the edkrepo utility
Other
21 stars 24 forks source link

SyntaxWarning on three regular expressions #251

Open ndhaller opened 2 months ago

ndhaller commented 2 months ago

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.