From: Hye-Shik Chang Date: Tue, 20 Apr 2004 21:11:11 +0000 (+0000) Subject: SF #926075: Fixed the bug that returns a wrong pattern object for X-Git-Tag: v2.4a1~483 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f5bf1ebdd426fb17f92d00b319a55b014021c30;p=python SF #926075: Fixed the bug that returns a wrong pattern object for a string or unicode object in sre.compile() when a different type pattern with the same value exists. --- diff --git a/Lib/sre.py b/Lib/sre.py index ffe2bc36e6..0ff70dc108 100644 --- a/Lib/sre.py +++ b/Lib/sre.py @@ -215,7 +215,8 @@ def _join(seq, sep): def _compile(*key): # internal: compile pattern - p = _cache.get(key) + cachekey = (type(key[0]),) + key + p = _cache.get(cachekey) if p is not None: return p pattern, flags = key @@ -229,7 +230,7 @@ def _compile(*key): raise error, v # invalid expression if len(_cache) >= _MAXCACHE: _cache.clear() - _cache[key] = p + _cache[cachekey] = p return p def _compile_repl(*key): diff --git a/Misc/NEWS b/Misc/NEWS index 2fb60230c2..b713316503 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -303,6 +303,10 @@ Extension modules Library ------- +- Bug #926075: Fixed a bug that returns a wrong pattern object + for a string or unicode object in sre.compile() when a different + type pattern with the same value exists. + - Added countcallers arg to trace.Trace class (--trackcalls command line arg when run from the command prompt).