Issue #1700, reported by Nguyen Quan Son, fix by Fredruk Lundh:
Regular Expression inline flags not handled correctly for some unicode characters.
This commit is contained in:
parent
309e241881
commit
6df9a82bd3
|
@ -525,7 +525,7 @@ def compile(p, flags=0):
|
|||
indexgroup[i] = k
|
||||
|
||||
return _sre.compile(
|
||||
pattern, flags, code,
|
||||
pattern, flags | p.pattern.flags, code,
|
||||
p.pattern.groups-1,
|
||||
groupindex, indexgroup
|
||||
)
|
||||
|
|
|
@ -637,6 +637,36 @@ class ReTests(unittest.TestCase):
|
|||
self.assertEqual(re.compile("bla").match(a), None)
|
||||
self.assertEqual(re.compile("").match(a).groups(), ())
|
||||
|
||||
def test_inline_flags(self):
|
||||
# Bug #1700
|
||||
upper_char = unichr(0x1ea0) # Latin Capital Letter A with Dot Bellow
|
||||
lower_char = unichr(0x1ea1) # Latin Small Letter A with Dot Bellow
|
||||
|
||||
p = re.compile(upper_char, re.I | re.U)
|
||||
q = p.match(lower_char)
|
||||
self.assertNotEqual(q, None)
|
||||
|
||||
p = re.compile(lower_char, re.I | re.U)
|
||||
q = p.match(upper_char)
|
||||
self.assertNotEqual(q, None)
|
||||
|
||||
p = re.compile('(?i)' + upper_char, re.U)
|
||||
q = p.match(lower_char)
|
||||
self.assertNotEqual(q, None)
|
||||
|
||||
p = re.compile('(?i)' + lower_char, re.U)
|
||||
q = p.match(upper_char)
|
||||
self.assertNotEqual(q, None)
|
||||
|
||||
p = re.compile('(?iu)' + upper_char)
|
||||
q = p.match(lower_char)
|
||||
self.assertNotEqual(q, None)
|
||||
|
||||
p = re.compile('(?iu)' + lower_char)
|
||||
q = p.match(upper_char)
|
||||
self.assertNotEqual(q, None)
|
||||
|
||||
|
||||
def run_re_tests():
|
||||
from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR
|
||||
if verbose:
|
||||
|
|
Loading…
Reference in New Issue