Skip to content

Commit 8d5ab0f

Browse files
Artalusuilianries
andauthored
Fix DeprecationWarning / SyntaxWarning in regex (#29)
Co-authored-by: Uilian Ries <uilianries@gmail.com>
1 parent 28de63c commit 8d5ab0f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

patch_ng.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def lineno(self):
424424
hunkparsed = False # state after successfully parsed hunk
425425

426426
# regexp to match start of hunk, used groups - 1,3,4,6
427-
re_hunk_start = re.compile(b"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@")
427+
re_hunk_start = re.compile(br"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@")
428428

429429
self.errors = 0
430430
# temp buffers for header and filenames info
@@ -575,7 +575,7 @@ def lineno(self):
575575
# strptime function and %z support is patchy, so we drop
576576
# everything from the . onwards and group the year and time
577577
# separately.
578-
re_filename_date_time = b"^--- ([^\t]+)(?:\s([0-9-]+)\s([0-9:]+)|.*)"
578+
re_filename_date_time = br"^--- ([^\t]+)(?:\s([0-9-]+)\s([0-9:]+)|.*)"
579579
match = re.match(re_filename_date_time, line)
580580
# todo: support spaces in filenames
581581
if match:
@@ -618,7 +618,7 @@ def lineno(self):
618618
filenames = False
619619
headscan = True
620620
else:
621-
re_filename_date_time = b"^\+\+\+ ([^\t]+)(?:\s([0-9-]+)\s([0-9:]+)|.*)"
621+
re_filename_date_time = br"^\+\+\+ ([^\t]+)(?:\s([0-9-]+)\s([0-9:]+)|.*)"
622622
match = re.match(re_filename_date_time, line)
623623
if not match:
624624
warning("skipping invalid patch - no target filename at line %d" % (lineno+1))
@@ -650,7 +650,7 @@ def lineno(self):
650650
continue
651651

652652
if hunkhead:
653-
match = re.match(b"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@(.*)", line)
653+
match = re.match(br"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@(.*)", line)
654654
if not match:
655655
if not p.hunks:
656656
warning("skipping invalid patch with no hunks for file %s" % p.source)

0 commit comments

Comments
 (0)