summaryrefslogtreecommitdiffstats
path: root/Lib/sre_compile.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2001-03-22 15:50:10 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2001-03-22 15:50:10 (GMT)
commitb25e1ad253a4d96aea31a7a3fb78522ea354f43a (patch)
tree2cc9dc18021270ffc2d7982ecca15b6942f59413 /Lib/sre_compile.py
parent8e9972c215ea0b10f0a7516d1cded6f26296ceba (diff)
downloadcpython-b25e1ad253a4d96aea31a7a3fb78522ea354f43a.zip
cpython-b25e1ad253a4d96aea31a7a3fb78522ea354f43a.tar.gz
cpython-b25e1ad253a4d96aea31a7a3fb78522ea354f43a.tar.bz2
sre 2.1b2 update:
- take locale into account for word boundary anchors (#410271) - restored 2.0's *? behaviour (#233283, #408936 and others) - speed up re.sub/re.subn
Diffstat (limited to 'Lib/sre_compile.py')
-rw-r--r--Lib/sre_compile.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
index ab2a2cc..44cb23e 100644
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -105,9 +105,12 @@ def _compile(code, pattern, flags):
elif op is AT:
emit(OPCODES[op])
if flags & SRE_FLAG_MULTILINE:
- emit(ATCODES[AT_MULTILINE.get(av, av)])
- else:
- emit(ATCODES[av])
+ av = AT_MULTILINE.get(av, av)
+ if flags & SRE_FLAG_LOCALE:
+ av = AT_LOCALE.get(av, av)
+ elif flags & SRE_FLAG_UNICODE:
+ av = AT_UNICODE.get(av, av)
+ emit(ATCODES[av])
elif op is BRANCH:
emit(OPCODES[op])
tail = []
@@ -124,11 +127,10 @@ def _compile(code, pattern, flags):
elif op is CATEGORY:
emit(OPCODES[op])
if flags & SRE_FLAG_LOCALE:
- emit(CHCODES[CH_LOCALE[av]])
+ av = CH_LOCALE[av]
elif flags & SRE_FLAG_UNICODE:
- emit(CHCODES[CH_UNICODE[av]])
- else:
- emit(CHCODES[av])
+ av = CH_UNICODE[av]
+ emit(CHCODES[av])
elif op is GROUPREF:
if flags & SRE_FLAG_IGNORECASE:
emit(OPCODES[OP_IGNORE[op]])