Patchwork D1794: py3: make regular expressions bytes by prepending b''

login
register
mail settings
Submitter phabricator
Date Dec. 29, 2017, 12:49 a.m.
Message ID <differential-rev-PHID-DREV-wv55iklzmgt4ppa4avme-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26490/
State Superseded
Headers show

Comments

phabricator - Dec. 29, 2017, 12:49 a.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Regexes start with r'' and hence transformer skips adding b'' there.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1794

AFFECTED FILES
  mercurial/byterange.py
  mercurial/mdiff.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 29, 2017, 1:52 a.m.
durin42 added a comment.


  For patches like this that are just adding bytes prefixes, let's go ahead and do a '# skip-blame' as in https://phab.mercurial-scm.org/rHGd92dc725223bbde09963fc431e57d32a40c4167d (aka https://phab.mercurial-scm.org/D1170) so that blame is cleaner in the future.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1794

To: pulkit, #hg-reviewers
Cc: durin42, mercurial-devel

Patch

diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -100,7 +100,7 @@ 
     if blank and opts.ignoreblanklines:
         text = re.sub('\n+', '\n', text).strip('\n')
     if opts.ignorewseol:
-        text = re.sub(r'[ \t\r\f]+\n', r'\n', text)
+        text = re.sub(br'[ \t\r\f]+\n', r'\n', text)
     return text
 
 def splitblock(base1, lines1, base2, lines2, opts):
diff --git a/mercurial/byterange.py b/mercurial/byterange.py
--- a/mercurial/byterange.py
+++ b/mercurial/byterange.py
@@ -416,7 +416,7 @@ 
     if range_header is None:
         return None
     if _rangere is None:
-        _rangere = re.compile(r'^bytes=(\d{1,})-(\d*)')
+        _rangere = re.compile(br'^bytes=(\d{1,})-(\d*)')
     match = _rangere.match(range_header)
     if match:
         tup = range_tuple_normalize(match.group(1, 2))