Bug 260729

Summary: SyntaxWarning when running 'git-webkit pr'
Product: WebKit Reporter: Michael Catanzaro <mcatanzaro>
Component: Tools / TestsAssignee: Michael Catanzaro <mcatanzaro>
Status: RESOLVED FIXED    
Severity: Normal CC: mcatanzaro, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Michael Catanzaro 2023-08-25 12:12:23 PDT
I see some errors when running 'git-webkit pr':

Downloading cryptography-36.0.2...
Installed cryptography-36.0.2!
Switched to a new branch 'eng/python-autoinstaller-is-broken-with-python-3-12'
Created the local development branch 'eng/python-autoinstaller-is-broken-with-python-3-12'
/home/mcatanzaro/Projects/WebKit/Tools/Scripts/webkitpy/common/checkout/checkout.py:52: SyntaxWarning: invalid escape sequence '\['
  COMMIT_SUBJECT_RE = re.compile(b'Subject: \[PATCH ?(\d+\/\d+)?] (.+)')
/home/mcatanzaro/Projects/WebKit/Tools/Scripts/webkitpy/common/checkout/checkout.py:53: SyntaxWarning: invalid escape sequence '\('
  FILTER_BRANCH_PROGRAM = '''import re
error: invalid key: branch.eng/python-autoinstaller-is-broken-with-python-3-12.cherry_picked
  Running status to find changed, added, or removed files.
  Reviewing diff to determine which lines changed.

The SyntaxWarning is new in python 3.12.

I will report a separate issue for the "error: invalid key" problem.
Comment 1 Michael Catanzaro 2023-08-25 12:14:14 PDT
(In reply to Michael Catanzaro from comment #0)
> I will report a separate issue for the "error: invalid key" problem.

Bug #260730
Comment 2 Michael Catanzaro 2023-08-25 12:34:07 PDT
Here is a fix:

diff --git a/Tools/Scripts/webkitpy/common/checkout/checkout.py b/Tools/Scripts/webkitpy/common/checkout/checkout.py
index aefa8c7b4d05..e2f72653e70c 100644
--- a/Tools/Scripts/webkitpy/common/checkout/checkout.py
+++ b/Tools/Scripts/webkitpy/common/checkout/checkout.py
@@ -49,8 +49,8 @@ if sys.version_info > (3, 0):
 # FIXME: Move a bunch of ChangeLog-specific processing from SCM to this object.
 # NOTE: All paths returned from this class should be absolute.
 class Checkout(object):
-    COMMIT_SUBJECT_RE = re.compile(b'Subject: \[PATCH ?(\d+\/\d+)?] (.+)')
-    FILTER_BRANCH_PROGRAM = '''import re
+    COMMIT_SUBJECT_RE = re.compile(r'Subject: \[PATCH ?(\d+\/\d+)?] (.+)')
+    FILTER_BRANCH_PROGRAM = r'''import re
 import sys
 
 lines = [l for l in sys.stdin]

I will create a pull request for this after bug #260726 is fixed.
Comment 3 Michael Catanzaro 2023-08-25 12:35:37 PDT
Oh, and the problem was the backslash \ is a python string escape rather than a regex escape. Each \ would need to be \\ to be a regex escape. The leading r switches to "raw string notation" to avoid this problem. https://docs.python.org/3.12/library/re.html
Comment 4 Michael Catanzaro 2023-08-29 13:19:21 PDT
Pull request: https://github.com/WebKit/WebKit/pull/17196
Comment 5 EWS 2023-09-01 10:48:46 PDT
Committed 267558@main (ade70bdb664e): <https://commits.webkit.org/267558@main>

Reviewed commits have been landed. Closing PR #17196 and removing active labels.
Comment 6 Radar WebKit Bug Importer 2023-09-01 10:49:16 PDT
<rdar://problem/114828777>