[yum-git] yum/misc.py yum/rpmsack.py yum/sqlitesack.py
James Antill
james at linux.duke.edu
Tue Apr 8 15:57:51 UTC 2008
yum/misc.py | 15 +++++++++++++--
yum/rpmsack.py | 2 +-
yum/sqlitesack.py | 2 +-
3 files changed, 15 insertions(+), 4 deletions(-)
New commits:
commit be587184635a4507a11a4c4123d1e7a38e18c6aa
Author: James Antill <james at and.org>
Date: Tue Apr 8 11:57:47 2008 -0400
Don't let the shared_data_store convert between str and unicode
diff --git a/yum/misc.py b/yum/misc.py
index 70af2cc..e1b9d4a 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -20,11 +20,22 @@ import gpgme
from Errors import MiscError
-_share_data_store = {}
+_share_data_store = {}
+_share_data_store_u = {}
def share_data(value):
""" Take a value and use the same value from the store,
if the value isn't in the store this one becomes the shared version. """
- return _share_data_store.setdefault(value, value)
+ # We don't want to change the types of strings, between str <=> unicode
+ # and hash('a') == hash(u'a') ... so use different stores.
+ # In theory eventaully we'll have all of one type, but don't hold breath.
+ store = _share_data_store
+ if isinstance(value, unicode):
+ store = _share_data_store_u
+ return store.setdefault(value, value)
+
+def unshare_data():
+ _share_data_store = {}
+ _share_data_store_u = {}
_re_compiled_glob_match = None
def re_glob(s):
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index c6bcbc0..dc4057c 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -123,7 +123,7 @@ class RPMDBPackageSack(PackageSackBase):
self._simple_pkgtup_list = []
self._get_pro_cache = {}
self._get_req_cache = {}
- misc._share_data_store = {}
+ misc.unshare_data()
self._cache = {
'provides' : { },
'requires' : { },
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index be34cdc..dfc5932 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -295,7 +295,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
'provides' : { },
'requires' : { },
}
- misc._share_data_store = {}
+ misc.unshare_data()
@catchSqliteException
def close(self):
More information about the Yum-cvs-commits
mailing list