Commit 7898c3e6 authored by Fredrik Lundh's avatar Fredrik Lundh

-- 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
parent 6947d0b6
......@@ -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)
......
This diff is collapsed.
......@@ -10,8 +10,6 @@
import string, sys
import _sre
from sre_constants import *
MAXREPEAT = 65535
......@@ -232,6 +230,7 @@ def _class_escape(source, escape):
return code
try:
if escape[1:2] == "x":
# FIXME: in 2.0, \xNN must have exactly two digits
while source.next in HEXDIGITS:
escape = escape + source.get()
escape = escape[2:]
......@@ -556,12 +555,13 @@ def _parse(source, state):
return subpattern
def parse(str, flags=0):
def parse(str, flags=0, pattern=None):
# parse 're' pattern into list of (opcode, argument) tuples
source = Tokenizer(str)
pattern = Pattern()
if pattern is None:
pattern = Pattern()
pattern.flags = flags
p = _parse_sub(source, pattern, 0)
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment