From 29950d3be0b14877587dec725eeabbb949e0d616 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 5 Mar 2009 03:03:50 +0000 Subject: [PATCH] Set Unpickler.find_global = None when possible and handle AttributeError for py3k. svn path=/main/trunk/; revision=12751 --- pym/_emerge/__init__.py | 5 +++++ pym/portage/__init__.py | 5 +++++ pym/portage/dbapi/vartree.py | 5 +++++ pym/portage/getbinpkg.py | 8 +++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 8abe080f9..a53d58a8f 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -4105,6 +4105,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 diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index b9365ff36..26860de80 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -7819,6 +7819,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 diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 7509f06f5..63705d27c 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1059,6 +1059,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 diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index bb3911a6b..02e5de277 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -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() -- 2.26.2