]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
SF #926075: Fixed the bug that returns a wrong pattern object for
authorHye-Shik Chang <hyeshik@gmail.com>
Tue, 20 Apr 2004 21:16:06 +0000 (21:16 +0000)
committerHye-Shik Chang <hyeshik@gmail.com>
Tue, 20 Apr 2004 21:16:06 +0000 (21:16 +0000)
a string or unicode object in sre.compile() when a different type
pattern with the same value exists.

Lib/sre.py
Misc/NEWS

index ffe2bc36e6439320c5cbc2ee691910f9e8a21750..0ff70dc1082b663c8c4034f3e7945f44714c743d 100644 (file)
@@ -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):
index 8d73eab69d875e47cd6501c08853f84e8400889d..b003799aedb5193f274d7dda09f6ae46f90f415f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -42,6 +42,10 @@ Core and builtins
 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.
+
 - Bug #924361: Properly support normalization of empty unicode strings.
 
 - Fixed a caching bug in platform.platform() where the argument of 'terse' was