From 6fa0c5a452ea935977b283955a1d49e5e23d97dc Mon Sep 17 00:00:00 2001
From: Gustavo Niemeyer <gustavo@niemeyer.net>
Date: Wed, 14 Sep 2005 08:54:39 +0000
Subject: [PATCH] Bug #1202493: Fixing SRE parser to handle '{}' as perl does,
 rather than considering it exactly like a '*'.

---
 Lib/sre_parse.py    | 3 +++
 Lib/test/test_re.py | 3 +++
 Misc/NEWS           | 4 ++++
 3 files changed, 10 insertions(+)

diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index 33b399ef654..319bf43b33f 100644
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -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 = ""
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index eab995de6e6..9755005f110 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -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)
diff --git a/Misc/NEWS b/Misc/NEWS
index 29f2b44ed74..27483d45a1b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -443,6 +443,10 @@ Library
   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
 -----
 
-- 
2.30.9