Patchwork D7552: tests: fix deprecation warning about regex flags not at beginning of expr

login
register
mail settings
Submitter phabricator
Date Dec. 6, 2019, 3:38 p.m.
Message ID <16402090f6391e883a9a81a4f3cdb81e@localhost.localdomain>
Download mbox | patch
Permalink /patch/43602/
State Not Applicable
Headers show

Comments

phabricator - Dec. 6, 2019, 3:38 p.m.
Closed by commit rHG3fe91bcd5199: tests: fix deprecation warning about regex flags not at beginning of expr (authored by spectral).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7552?vs=18477&id=18491

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7552/new/

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS




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

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1973,7 +1973,11 @@ 
     @staticmethod
     def rematch(el, l):
         try:
-            el = b'(?:' + el + b')'
+            # parse any flags at the beginning of the regex. Only 'i' is
+            # supported right now, but this should be easy to extend.
+            flags, el = re.match(br'^(\(\?i\))?(.*)', el).groups()[0:2]
+            flags = flags or b''
+            el = flags + b'(?:' + el + b')'
             # use \Z to ensure that the regex matches to the end of the string
             if os.name == 'nt':
                 return re.match(el + br'\r?\n\Z', l)