Commits

Georg Brandl  committed 9a2e203

Bug #1202493: Fixing SRE parser to handle '{}' as perl does, rather than
considering it exactly like a '*'.

Backport from 2.5 branch.

  • Participants
  • Parent commits 4806cb0
  • Branches 2.4

Comments (0)

Files changed (3)

File Lib/sre_parse.py

             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 = ""

File Lib/test/test_re.py

         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)
   from the input stream, so that the output is a byte string in the correct
   encoding instead of a unicode string.
 
+- Bug #1202493: Fixing SRE parser to handle '{}' as perl does, rather than
+  considering it exactly like a '*'.
+
+
 Build
 -----