conan-io / python-patch-ng

Library to parse and apply unified diffs
https://pypi.org/project/patch-ng
Other
19 stars 8 forks source link

Fix DeprecationWarning / SyntaxWarning in regex #29

Closed Artalus closed 3 months ago

Artalus commented 3 months ago

Starting with Python 3.12, Conan verbosely complains about deprecated syntax in patch_ng:

$ conan
/tmp/conan2/.venv/lib/python3.12/site-packages/patch_ng.py:427: SyntaxWarning: invalid escape sequence '\d'
  re_hunk_start = re.compile(b"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@")
/tmp/conan2/.venv/lib/python3.12/site-packages/patch_ng.py:578: SyntaxWarning: invalid escape sequence '\s'
  re_filename_date_time = b"^--- ([^\t]+)(?:\s([0-9-]+)\s([0-9:]+)|.*)"
/tmp/conan2/.venv/lib/python3.12/site-packages/patch_ng.py:621: SyntaxWarning: invalid escape sequence '\+'
  re_filename_date_time = b"^\+\+\+ ([^\t]+)(?:\s([0-9-]+)\s([0-9:]+)|.*)"
/tmp/conan2/.venv/lib/python3.12/site-packages/patch_ng.py:653: SyntaxWarning: invalid escape sequence '\d'
  match = re.match(b"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@(.*)", line)

Consumer commands
cache      Perform file operations in the local cache (of recipes and/or packages).
...

What was DeprecationWarning in older Pythons (see #22) is now a SyntaxWarning - which is probably why they now appear in Conan output.

This was fixed in upstream in the PR merged after this fork was created: techtonik#72

Closes #22

Closes #10

uilianries commented 3 months ago

Hello @Artalus !! Thank you for pushing this hotfix! We gonna merge the PR #30 first, so we can run the CI again and validate your PR. At first sight it looks totally fine.

uilianries commented 3 months ago

@Artalus your PR is merged, thank you! We will be looking other issues along the week, before preparing a new release.