Bug #1202493: Fixing SRE parser to handle '{}' as perl does, rather than
considering it exactly like a '*'.
This commit is contained in:
parent
0c55f2946b
commit
6fa0c5a452
|
@ -485,6 +485,9 @@ def _parse(source, state):
|
|||
elif this == "+":
|
||||
min, max = 1, MAXREPEAT
|
||||
elif this == "{":
|
||||
if source.next == "}":
|
||||
subpatternappend((LITERAL, ord(this)))
|
||||
continue
|
||||
here = source.tell()
|
||||
min, max = 0, MAXREPEAT
|
||||
lo = hi = ""
|
||||
|
|
|
@ -297,6 +297,9 @@ class ReTests(unittest.TestCase):
|
|||
self.assertNotEqual(re.match("^x{1,4}?$", "xxx"), None)
|
||||
self.assertNotEqual(re.match("^x{3,4}?$", "xxx"), None)
|
||||
|
||||
self.assertEqual(re.match("^x{}$", "xxx"), None)
|
||||
self.assertNotEqual(re.match("^x{}$", "x{}"), None)
|
||||
|
||||
def test_getattr(self):
|
||||
self.assertEqual(re.match("(a)", "a").pos, 0)
|
||||
self.assertEqual(re.match("(a)", "a").endpos, 1)
|
||||
|
|
Loading…
Reference in New Issue