Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53d93ad

Browse files
committed
Patch #681152: Support escaped Unicode characters in classes. Fixes #612074.
Will backport to 2.2.
1 parent 910ae62 commit 53d93ad

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/sre_parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def _class_escape(source, escape):
254254
if len(escape) != 2:
255255
raise error, "bogus escape: %s" % repr("\\" + escape)
256256
return LITERAL, atoi(escape, 16) & 0xff
257-
elif str(escape[1:2]) in OCTDIGITS:
257+
elif escape[1:2] in OCTDIGITS:
258258
# octal escape (up to three digits)
259259
while source.next in OCTDIGITS and len(escape) < 5:
260260
escape = escape + source.get()

Lib/test/test_sre.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ def test(expression, result, exception=None):
9696
# non-simple '*?' still recurses and hits the recursion limit
9797
test(r"""sre.search('(a|b)*?c', 10000*'ab'+'cd').end(0)""", None, RuntimeError)
9898

99+
# bug 612074
100+
pat=u"["+sre.escape(u"\u2039")+u"]"
101+
test(r"""sre.compile(pat) and 1""", 1, None)
102+
99103
if verbose:
100104
print 'Running tests on sre.sub'
101105

0 commit comments

Comments
 (0)