From: Martin v. Löwis Date: Sat, 19 Apr 2003 08:39:04 +0000 (+0000) Subject: Patch #681152: Support escaped unicode characters in classes. Fixes 612074. X-Git-Tag: v2.2.3c1~67 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c29daeb119aad54ca276d8c00e4c0d2bde1273f;p=thirdparty%2FPython%2Fcpython.git Patch #681152: Support escaped unicode characters in classes. Fixes 612074. --- diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index f6b53de6ea2d..555dc82b3b1c 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -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() diff --git a/Lib/test/test_sre.py b/Lib/test/test_sre.py index abd55db1d64d..d4a052f651d1 100644 --- a/Lib/test/test_sre.py +++ b/Lib/test/test_sre.py @@ -78,6 +78,10 @@ test(r"""sre.match(r'(a)|(b)', 'b').start(1)""", -1) test(r"""sre.match(r'(a)|(b)', 'b').end(1)""", -1) test(r"""sre.match(r'(a)|(b)', 'b').span(1)""", (-1, -1)) +# 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'