mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-30215: Make re.compile() locale agnostic. (#1361)
Compiled regular expression objects with the re.LOCALE flag no longer depend on the locale at compile time. Only the locale at matching time affects the result of matching.
This commit is contained in:
parent
647c3d381e
commit
898ff03e1e
9 changed files with 141 additions and 23 deletions
|
@ -13,7 +13,7 @@
|
|||
|
||||
# update when constants are added or removed
|
||||
|
||||
MAGIC = 20140917
|
||||
MAGIC = 20170530
|
||||
|
||||
from _sre import MAXREPEAT, MAXGROUPS
|
||||
|
||||
|
@ -87,6 +87,9 @@ OPCODES = _makecodes("""
|
|||
SUBPATTERN
|
||||
MIN_REPEAT_ONE
|
||||
RANGE_IGNORE
|
||||
LITERAL_LOC_IGNORE
|
||||
NOT_LITERAL_LOC_IGNORE
|
||||
IN_LOC_IGNORE
|
||||
|
||||
MIN_REPEAT MAX_REPEAT
|
||||
""")
|
||||
|
@ -124,6 +127,11 @@ OP_IGNORE = {
|
|||
RANGE: RANGE_IGNORE,
|
||||
}
|
||||
|
||||
OP_LOC_IGNORE = {
|
||||
LITERAL: LITERAL_LOC_IGNORE,
|
||||
NOT_LITERAL: NOT_LITERAL_LOC_IGNORE,
|
||||
}
|
||||
|
||||
AT_MULTILINE = {
|
||||
AT_BEGINNING: AT_BEGINNING_LINE,
|
||||
AT_END: AT_END_LINE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue