Kaydet (Commit) 6fa0c5a4 authored tarafından Gustavo Niemeyer's avatar Gustavo Niemeyer

Bug #1202493: Fixing SRE parser to handle '{}' as perl does, rather than

considering it exactly like a '*'.
üst 0c55f294
...@@ -485,6 +485,9 @@ def _parse(source, state): ...@@ -485,6 +485,9 @@ def _parse(source, state):
elif this == "+": elif this == "+":
min, max = 1, MAXREPEAT min, max = 1, MAXREPEAT
elif this == "{": elif this == "{":
if source.next == "}":
subpatternappend((LITERAL, ord(this)))
continue
here = source.tell() here = source.tell()
min, max = 0, MAXREPEAT min, max = 0, MAXREPEAT
lo = hi = "" lo = hi = ""
......
...@@ -297,6 +297,9 @@ class ReTests(unittest.TestCase): ...@@ -297,6 +297,9 @@ class ReTests(unittest.TestCase):
self.assertNotEqual(re.match("^x{1,4}?$", "xxx"), None) self.assertNotEqual(re.match("^x{1,4}?$", "xxx"), None)
self.assertNotEqual(re.match("^x{3,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): def test_getattr(self):
self.assertEqual(re.match("(a)", "a").pos, 0) self.assertEqual(re.match("(a)", "a").pos, 0)
self.assertEqual(re.match("(a)", "a").endpos, 1) self.assertEqual(re.match("(a)", "a").endpos, 1)
......
...@@ -443,6 +443,10 @@ Library ...@@ -443,6 +443,10 @@ Library
from the input stream, so that the output is a byte string in the correct from the input stream, so that the output is a byte string in the correct
encoding instead of a unicode string. encoding instead of a unicode string.
- Bug #1202493: Fixing SRE parser to handle '{}' as perl does, rather than
considering it exactly like a '*'.
Build Build
----- -----
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment