1 |
commit: bc636fe8f9720957f29e5a07cd98531f20368ddd |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Sep 3 18:39:05 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Sep 3 18:39:05 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=bc636fe8 |
7 |
|
8 |
Handle unpickle AttributeError (bug #381705). |
9 |
|
10 |
--- |
11 |
pym/_emerge/BlockerCache.py | 10 +++++++--- |
12 |
pym/portage/dbapi/vartree.py | 7 +++++-- |
13 |
pym/portage/getbinpkg.py | 2 +- |
14 |
.../util/_dyn_libs/PreservedLibsRegistry.py | 2 +- |
15 |
pym/portage/util/mtimedb.py | 8 ++++++-- |
16 |
5 files changed, 20 insertions(+), 9 deletions(-) |
17 |
|
18 |
diff --git a/pym/_emerge/BlockerCache.py b/pym/_emerge/BlockerCache.py |
19 |
index 5c4f43e..8a1c884 100644 |
20 |
--- a/pym/_emerge/BlockerCache.py |
21 |
+++ b/pym/_emerge/BlockerCache.py |
22 |
@@ -1,6 +1,7 @@ |
23 |
-# Copyright 1999-2009 Gentoo Foundation |
24 |
+# Copyright 1999-2011 Gentoo Foundation |
25 |
# Distributed under the terms of the GNU General Public License v2 |
26 |
|
27 |
+import errno |
28 |
import sys |
29 |
from portage.util import writemsg |
30 |
from portage.data import secpass |
31 |
@@ -58,8 +59,11 @@ class BlockerCache(portage.cache.mappings.MutableMapping): |
32 |
self._cache_data = mypickle.load() |
33 |
f.close() |
34 |
del f |
35 |
- except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError) as e: |
36 |
- if isinstance(e, pickle.UnpicklingError): |
37 |
+ except (AttributeError, EnvironmentError, ValueError, pickle.UnpicklingError) as e: |
38 |
+ if isinstance(e, EnvironmentError) and \ |
39 |
+ getattr(e, 'errno', None) in (errno.ENOENT, errno.EACCES): |
40 |
+ pass |
41 |
+ else: |
42 |
writemsg("!!! Error loading '%s': %s\n" % \ |
43 |
(self._cache_filename, str(e)), noiselevel=-1) |
44 |
del e |
45 |
|
46 |
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py |
47 |
index ba2cc08..4df0576 100644 |
48 |
--- a/pym/portage/dbapi/vartree.py |
49 |
+++ b/pym/portage/dbapi/vartree.py |
50 |
@@ -555,8 +555,11 @@ class vardbapi(dbapi): |
51 |
aux_cache = mypickle.load() |
52 |
f.close() |
53 |
del f |
54 |
- except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError) as e: |
55 |
- if isinstance(e, pickle.UnpicklingError): |
56 |
+ except (AttributeError, EnvironmentError, ValueError, pickle.UnpicklingError) as e: |
57 |
+ if isinstance(e, EnvironmentError) and \ |
58 |
+ getattr(e, 'errno', None) in (errno.ENOENT, errno.EACCES): |
59 |
+ pass |
60 |
+ else: |
61 |
writemsg(_unicode_decode(_("!!! Error loading '%s': %s\n")) % \ |
62 |
(self._aux_cache_filename, e), noiselevel=-1) |
63 |
del e |
64 |
|
65 |
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py |
66 |
index a511f51..a83e2a5 100644 |
67 |
--- a/pym/portage/getbinpkg.py |
68 |
+++ b/pym/portage/getbinpkg.py |
69 |
@@ -542,7 +542,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache= |
70 |
out.write(_("Loaded metadata pickle.\n")) |
71 |
out.flush() |
72 |
metadatafile.close() |
73 |
- except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError): |
74 |
+ except (AttributeError, EnvironmentError, ValueError, pickle.UnpicklingError): |
75 |
metadata = {} |
76 |
if baseurl not in metadata: |
77 |
metadata[baseurl]={} |
78 |
|
79 |
diff --git a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py |
80 |
index b916051..a181498 100644 |
81 |
--- a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py |
82 |
+++ b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py |
83 |
@@ -60,7 +60,7 @@ class PreservedLibsRegistry(object): |
84 |
f = open(_unicode_encode(self._filename, |
85 |
encoding=_encodings['fs'], errors='strict'), 'rb') |
86 |
self._data = pickle.load(f) |
87 |
- except (ValueError, pickle.UnpicklingError) as e: |
88 |
+ except (AttributeError, ValueError, pickle.UnpicklingError) as e: |
89 |
writemsg_level(_("!!! Error loading '%s': %s\n") % \ |
90 |
(self._filename, e), level=logging.ERROR, noiselevel=-1) |
91 |
except (EOFError, IOError) as e: |
92 |
|
93 |
diff --git a/pym/portage/util/mtimedb.py b/pym/portage/util/mtimedb.py |
94 |
index 67f93e8..bc4f97c 100644 |
95 |
--- a/pym/portage/util/mtimedb.py |
96 |
+++ b/pym/portage/util/mtimedb.py |
97 |
@@ -9,6 +9,7 @@ try: |
98 |
except ImportError: |
99 |
import pickle |
100 |
|
101 |
+import errno |
102 |
import portage |
103 |
from portage import _unicode_encode |
104 |
from portage.data import portage_gid, uid |
105 |
@@ -33,8 +34,11 @@ class MtimeDB(dict): |
106 |
d = mypickle.load() |
107 |
f.close() |
108 |
del f |
109 |
- except (IOError, OSError, EOFError, ValueError, pickle.UnpicklingError) as e: |
110 |
- if isinstance(e, pickle.UnpicklingError): |
111 |
+ except (AttributeError, EnvironmentError, ValueError, pickle.UnpicklingError) as e: |
112 |
+ if isinstance(e, EnvironmentError) and \ |
113 |
+ getattr(e, 'errno', None) in (errno.ENOENT, errno.EACCES): |
114 |
+ pass |
115 |
+ else: |
116 |
writemsg(_("!!! Error loading '%s': %s\n") % \ |
117 |
(filename, str(e)), noiselevel=-1) |
118 |
del e |