]> granicus.if.org Git - python/commitdiff
Patch #681152: Support escaped Unicode characters in classes. Fixes #612074.
authorMartin v. Löwis <martin@v.loewis.de>
Sat, 19 Apr 2003 08:37:24 +0000 (08:37 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sat, 19 Apr 2003 08:37:24 +0000 (08:37 +0000)
Will backport to 2.2.

Lib/sre_parse.py
Lib/test/test_sre.py

index fdf6767367f98df038ca0b97a288db5816b6759b..b85aea70a4fbc3c7f0a3852b50bf3aacf4d242e8 100644 (file)
@@ -254,7 +254,7 @@ def _class_escape(source, escape):
             if len(escape) != 2:
                 raise error, "bogus escape: %s" % repr("\\" + escape)
             return LITERAL, atoi(escape, 16) & 0xff
-        elif str(escape[1:2]) in OCTDIGITS:
+        elif escape[1:2] in OCTDIGITS:
             # octal escape (up to three digits)
             while source.next in OCTDIGITS and len(escape) < 5:
                 escape = escape + source.get()
index e4eb08ddd714df4fdad8977f7566077636a4da80..db871620fac6597a676fa7cad1bc5f783d6d9c38 100644 (file)
@@ -96,6 +96,10 @@ test(r"""sre.match('.*?cd', 20000*'abc'+'de').end(0)""", 60001)
 # non-simple '*?' still recurses and hits the recursion limit
 test(r"""sre.search('(a|b)*?c', 10000*'ab'+'cd').end(0)""", None, RuntimeError)
 
+# bug 612074
+pat=u"["+sre.escape(u"\u2039")+u"]"
+test(r"""sre.compile(pat) and 1""", 1, None)
+
 if verbose:
     print 'Running tests on sre.sub'