summaryrefslogtreecommitdiffstats
path: root/Lib/sre.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-08-07 20:59:04 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2000-08-07 20:59:04 (GMT)
commit7898c3e6852565046a9b8b063d35d66777bf5176 (patch)
treee4846002d94c6f96d180cde05a6ccac095287de6 /Lib/sre.py
parent6947d0b65eb21606de8e17b180bf116421d23116 (diff)
downloadcpython-7898c3e6852565046a9b8b063d35d66777bf5176.zip
cpython-7898c3e6852565046a9b8b063d35d66777bf5176.tar.gz
cpython-7898c3e6852565046a9b8b063d35d66777bf5176.tar.bz2
-- reset marks if repeat_one tail doesn't match
(this should fix Sjoerd's xmllib problem) -- added skip field to INFO header -- changed compiler to generate charset INFO header -- changed trace messages to support post-mortem analysis
Diffstat (limited to 'Lib/sre.py')
-rw-r--r--Lib/sre.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/Lib/sre.py b/Lib/sre.py
index edfefc1..b1ed9fb 100644
--- a/Lib/sre.py
+++ b/Lib/sre.py
@@ -47,16 +47,16 @@ def search(pattern, string, flags=0):
return _compile(pattern, flags).search(string)
def sub(pattern, repl, string, count=0):
- return _compile(pattern).sub(repl, string, count)
+ return _compile(pattern, 0).sub(repl, string, count)
def subn(pattern, repl, string, count=0):
- return _compile(pattern).subn(repl, string, count)
+ return _compile(pattern, 0).subn(repl, string, count)
def split(pattern, string, maxsplit=0):
- return _compile(pattern).split(string, maxsplit)
+ return _compile(pattern, 0).split(string, maxsplit)
def findall(pattern, string, maxsplit=0):
- return _compile(pattern).findall(string, maxsplit)
+ return _compile(pattern, 0).findall(string, maxsplit)
def compile(pattern, flags=0):
return _compile(pattern, flags)
@@ -88,16 +88,14 @@ def _join(seq, sep):
# internal: join into string having the same type as sep
return string.join(seq, sep[:0])
-def _compile(pattern, flags=0):
+def _compile(*key):
# internal: compile pattern
- tp = type(pattern)
- if tp not in sre_compile.STRING_TYPES:
+ p = _cache.get(key)
+ if p is not None:
+ return p
+ pattern, flags = key
+ if type(pattern) not in sre_compile.STRING_TYPES:
return pattern
- key = (tp, pattern, flags)
- try:
- return _cache[key]
- except KeyError:
- pass
try:
p = sre_compile.compile(pattern, flags)
except error, v:
@@ -168,7 +166,7 @@ import copy_reg
def _pickle(p):
return _compile, (p.pattern, p.flags)
-copy_reg.pickle(type(_compile("")), _pickle, _compile)
+copy_reg.pickle(type(_compile("", 0)), _pickle, _compile)
# --------------------------------------------------------------------
# experimental stuff (see python-dev discussions for details)