summaryrefslogtreecommitdiffstats
path: root/Lib/sre.py
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2001-10-18 19:30:16 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2001-10-18 19:30:16 (GMT)
commit397a654791e6bc8b108945e45e7d1393cc6f32d4 (patch)
tree0bcf95e153017bddb35c1549d2e7c9e31f676111 /Lib/sre.py
parent3bb4d214a470c4da4af63f5a2c098cc886b9e857 (diff)
downloadcpython-397a654791e6bc8b108945e45e7d1393cc6f32d4.zip
cpython-397a654791e6bc8b108945e45e7d1393cc6f32d4.tar.gz
cpython-397a654791e6bc8b108945e45e7d1393cc6f32d4.tar.bz2
SRE bug #441409:
compile should raise error for non-strings SRE bug #432570, 448951: reset group after failed match also bumped version number to 2.2.0
Diffstat (limited to 'Lib/sre.py')
-rw-r--r--Lib/sre.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/sre.py b/Lib/sre.py
index 7a640f9..70d0148 100644
--- a/Lib/sre.py
+++ b/Lib/sre.py
@@ -104,7 +104,7 @@ __all__ = [ "match", "search", "sub", "subn", "split", "findall",
"U", "IGNORECASE", "LOCALE", "MULTILINE", "DOTALL", "VERBOSE",
"UNICODE", "error" ]
-__version__ = "2.1.1"
+__version__ = "2.2.0"
# this module works under 1.5.2 and later. don't use string methods
import string
@@ -197,6 +197,8 @@ def escape(pattern):
_cache = {}
_cache_repl = {}
+_pattern_type = type(sre_compile.compile("", 0))
+
_MAXCACHE = 100
def _join(seq, sep):
@@ -209,8 +211,10 @@ def _compile(*key):
if p is not None:
return p
pattern, flags = key
- if type(pattern) not in sre_compile.STRING_TYPES:
+ if type(pattern) is _pattern_type:
return pattern
+ if type(pattern) not in sre_compile.STRING_TYPES:
+ raise TypeError, "first argument must be string or compiled pattern"
try:
p = sre_compile.compile(pattern, flags)
except error, v:
@@ -312,7 +316,7 @@ import copy_reg
def _pickle(p):
return _compile, (p.pattern, p.flags)
-copy_reg.pickle(type(_compile("", 0)), _pickle, _compile)
+copy_reg.pickle(_pattern_type, _pickle, _compile)
# --------------------------------------------------------------------
# experimental stuff (see python-dev discussions for details)