Skip to content

SyntaxWarning on three regular expressions #251

Closed
@ndhaller

Description

@ndhaller

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions