Set Unpickler.find_global = None when possible and handle AttributeError
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:38:13 +0000 (06:38 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:38:13 +0000 (06:38 -0000)
for py3k. (trunk r12751)

svn path=/main/branches/2.1.6/; revision=12999

pym/_emerge/__init__.py
pym/portage/__init__.py
pym/portage/dbapi/vartree.py
pym/portage/getbinpkg.py

index 23a051d5b4da2a126c3fc063a9de55f52ea3c69f..6431edc26bc352987aa7c056c709b76deb377b5f 100644 (file)
@@ -4089,6 +4089,11 @@ class BlockerCache(portage.cache.mappings.MutableMapping):
                try:
                        f = open(self._cache_filename, mode='rb')
                        mypickle = pickle.Unpickler(f)
+                       try:
+                               mypickle.find_global = None
+                       except AttributeError:
+                               # TODO: If py3k, override Unpickler.find_class().
+                               pass
                        self._cache_data = mypickle.load()
                        f.close()
                        del f
index 20de5af10d4d4015ff99e297ddc4558a19cf8a85..9eae9845cb552d7a89bcfebfce945d84ebbc25fb 100644 (file)
@@ -7806,6 +7806,11 @@ class MtimeDB(dict):
                try:
                        f = open(filename, 'rb')
                        mypickle = pickle.Unpickler(f)
+                       try:
+                               mypickle.find_global = None
+                       except AttributeError:
+                               # TODO: If py3k, override Unpickler.find_class().
+                               pass
                        d = mypickle.load()
                        f.close()
                        del f
index 5f12715d388e1e34fcccef5a3162d45dc2967135..c3684b8439a6b06450febf1010ac3561b534d69f 100644 (file)
@@ -404,6 +404,11 @@ class vardbapi(dbapi):
                try:
                        f = open(self._aux_cache_filename, mode='rb', **open_kwargs)
                        mypickle = pickle.Unpickler(f)
+                       try:
+                               mypickle.find_global = None
+                       except AttributeError:
+                               # TODO: If py3k, override Unpickler.find_class().
+                               pass
                        aux_cache = mypickle.load()
                        f.close()
                        del f
index bb3911a6b57e521f723e54591cb655c86c49b7e8..02e5de27761c5577b6dffe0baed2d37ccd260018 100644 (file)
@@ -486,7 +486,13 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
        out = sys.stdout
        try:
                metadatafile = open(metadatafilename, 'rb')
-               metadata = pickle.load(metadatafile)
+               mypickle = pickle.Unpickler(metadatafile)
+               try:
+                       mypickle.find_global = None
+               except AttributeError:
+                       # TODO: If py3k, override Unpickler.find_class().
+                       pass
+               metadata = mypickle.load()
                out.write("Loaded metadata pickle.\n")
                out.flush()
                metadatafile.close()