Skip to content

Commit 577fb5a

Browse files
committed
Fix from SF patch #633359 by Greg Chapman for SF bug #610299:
The problem is in sre_compile.py: the call to _compile_charset near the end of _compile_info forgets to pass in the flags, so that the info charset is not compiled with re.U. (The info charset is used when searching to find the first character at which a match could start; it is not generated for patterns beginning with a repeat like '\w{1}'.)
1 parent 902a671 commit 577fb5a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Lib/sre_compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def _compile_info(code, pattern, flags):
399399
table[i+1] = table[table[i+1]-1]+1
400400
code.extend(table[1:]) # don't store first entry
401401
elif charset:
402-
_compile_charset(charset, 0, code)
402+
_compile_charset(charset, flags, code)
403403
code[skip] = len(code) - skip
404404

405405
STRING_TYPES = [type("")]

Lib/test/re_tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,4 +666,5 @@
666666
# bug 410271: \b broken under locales
667667
(r'\b.\b', 'a', SUCCEED, 'found', 'a'),
668668
(r'(?u)\b.\b', u, SUCCEED, 'found', u),
669+
(r'(?u)\w', u, SUCCEED, 'found', u),
669670
])

0 commit comments

Comments
 (0)