From edbcb5731d3478e7e7ec5e6154b27bb4385eec31 Mon Sep 17 00:00:00 2001 From: Artalus Date: Wed, 31 Jul 2024 14:30:25 +0400 Subject: [PATCH] fix DeprecationWarning / SyntaxWarning in regex --- patch_ng.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patch_ng.py b/patch_ng.py index 088fbba..9556eb2 100755 --- a/patch_ng.py +++ b/patch_ng.py @@ -424,7 +424,7 @@ def lineno(self): hunkparsed = False # state after successfully parsed hunk # regexp to match start of hunk, used groups - 1,3,4,6 - re_hunk_start = re.compile(b"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@") + re_hunk_start = re.compile(br"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@") self.errors = 0 # temp buffers for header and filenames info @@ -575,7 +575,7 @@ def lineno(self): # strptime function and %z support is patchy, so we drop # everything from the . onwards and group the year and time # separately. - re_filename_date_time = b"^--- ([^\t]+)(?:\s([0-9-]+)\s([0-9:]+)|.*)" + re_filename_date_time = br"^--- ([^\t]+)(?:\s([0-9-]+)\s([0-9:]+)|.*)" match = re.match(re_filename_date_time, line) # todo: support spaces in filenames if match: @@ -618,7 +618,7 @@ def lineno(self): filenames = False headscan = True else: - re_filename_date_time = b"^\+\+\+ ([^\t]+)(?:\s([0-9-]+)\s([0-9:]+)|.*)" + re_filename_date_time = br"^\+\+\+ ([^\t]+)(?:\s([0-9-]+)\s([0-9:]+)|.*)" match = re.match(re_filename_date_time, line) if not match: warning("skipping invalid patch - no target filename at line %d" % (lineno+1)) @@ -650,7 +650,7 @@ def lineno(self): continue if hunkhead: - match = re.match(b"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@(.*)", line) + match = re.match(br"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@(.*)", line) if not match: if not p.hunks: warning("skipping invalid patch with no hunks for file %s" % p.source)