]> granicus.if.org Git - python/commitdiff
Issue #28070: Fixed parsing inline verbose flag in regular expressions.
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 10 Sep 2016 22:39:01 +0000 (01:39 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 10 Sep 2016 22:39:01 +0000 (01:39 +0300)
Lib/sre_parse.py
Lib/test/test_re.py
Misc/NEWS

index 09f3be25ab9f6da55b9696ffaeb1ee15d9602832..d74e93ff5c854f52dff22b80cf17e3b916112bd7 100644 (file)
@@ -847,6 +847,7 @@ def parse(str, flags=0, pattern=None):
         pattern = Pattern()
         pattern.flags = flags | SRE_FLAG_VERBOSE
         pattern.str = str
+        source.seek(0)
         p = _parse_sub(source, pattern, True, False)
 
     p.pattern.flags = fix_flags(str, p.pattern.flags)
index 2322ca9bb4570a460a0b6f8eb0dcba62c79b503c..afe8738e8372a6709c1d86d5e2beb222515c7d5d 100644 (file)
@@ -1276,6 +1276,9 @@ class ReTests(unittest.TestCase):
         q = p.match(upper_char)
         self.assertTrue(q)
 
+        self.assertTrue(re.match('(?ixu) ' + upper_char, lower_char))
+        self.assertTrue(re.match('(?ixu) ' + lower_char, upper_char))
+
     def test_dollar_matches_twice(self):
         "$ matches the end of string, and just before the terminating \n"
         pattern = re.compile('$')
index 8c4fbc92cd698a6a608fe7030e47e7bab4ecca87..7ce539150ec809ecc2a2ff80c816996d8df90a99 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -138,6 +138,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #28070: Fixed parsing inline verbose flag in regular expressions.
+
 - Issue #19500: Add client-side SSL session resumption to the ssl module.
 
 - Issue #28022: Deprecate ssl-related arguments in favor of SSLContext. The