summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/__init__.py14
-rw-r--r--pym/portage/__init__.py5
-rw-r--r--pym/portage/dbapi/vartree.py9
-rw-r--r--pym/portage/getbinpkg.py9
-rw-r--r--pym/portage/util.py3
5 files changed, 15 insertions, 25 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 830a6d5b4..413792606 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -4043,9 +4043,8 @@ class BlockerCache(portage.cache.mappings.MutableMapping):
def _load(self):
try:
- f = open(self._cache_filename)
+ f = open(self._cache_filename, mode='rb')
mypickle = pickle.Unpickler(f)
- mypickle.find_global = None
self._cache_data = mypickle.load()
f.close()
del f
@@ -4129,7 +4128,7 @@ class BlockerCache(portage.cache.mappings.MutableMapping):
if len(self._modified) >= self._cache_threshold and \
secpass >= 2:
try:
- f = portage.util.atomic_ofstream(self._cache_filename)
+ f = portage.util.atomic_ofstream(self._cache_filename, mode='wb')
pickle.dump(self._cache_data, f, -1)
f.close()
portage.util.apply_secpass_permissions(
@@ -14423,14 +14422,7 @@ def action_build(settings, trees, mtimedb,
# a list type for options.
mtimedb["resume"]["myopts"] = myopts.copy()
- # Convert Atom instances to plain str since the mtimedb loader
- # sets unpickler.find_global = None which causes unpickler.load()
- # to raise the following exception:
- #
- # cPickle.UnpicklingError: Global and instance pickles are not supported.
- #
- # TODO: Maybe stop setting find_global = None, or find some other
- # way to avoid accidental triggering of the above UnpicklingError.
+ # Convert Atom instances to plain str.
mtimedb["resume"]["favorites"] = [str(x) for x in favorites]
if ("--digest" in myopts) and not ("--fetchonly" in myopts or "--fetch-all-uri" in myopts):
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index fa4e721be..9769f3607 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -7439,7 +7439,7 @@ def commit_mtimedb(mydict=None, filename=None):
d = {} # for full backward compat, pickle it as a plain dict object.
d.update(mydict)
try:
- f = atomic_ofstream(filename)
+ f = atomic_ofstream(filename, mode='wb')
pickle.dump(d, f, -1)
f.close()
portage.util.apply_secpass_permissions(filename, uid=uid, gid=portage_gid, mode=0664)
@@ -7604,9 +7604,8 @@ class MtimeDB(dict):
def _load(self, filename):
try:
- f = open(filename)
+ f = open(filename, 'rb')
mypickle = pickle.Unpickler(f)
- mypickle.find_global = None
d = mypickle.load()
f.close()
del f
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index b7cee710c..14c5360e2 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -58,7 +58,7 @@ class PreservedLibsRegistry(object):
def load(self):
""" Reload the registry data from file """
try:
- self._data = pickle.load(open(self._filename, "r"))
+ self._data = pickle.load(open(self._filename, 'rb'))
except (EOFError, IOError), e:
if isinstance(e, EOFError) or e.errno == errno.ENOENT:
self._data = {}
@@ -75,7 +75,7 @@ class PreservedLibsRegistry(object):
self._data == self._data_orig:
return
try:
- f = atomic_ofstream(self._filename)
+ f = atomic_ofstream(self._filename, 'wb')
pickle.dump(self._data, f)
f.close()
except EnvironmentError, e:
@@ -1027,7 +1027,7 @@ class vardbapi(dbapi):
del self._aux_cache["packages"][cpv]
del self._aux_cache["modified"]
try:
- f = atomic_ofstream(self._aux_cache_filename)
+ f = atomic_ofstream(self._aux_cache_filename, 'wb')
pickle.dump(self._aux_cache, f, -1)
f.close()
apply_secpass_permissions(
@@ -1045,9 +1045,8 @@ class vardbapi(dbapi):
def _aux_cache_init(self):
aux_cache = None
try:
- f = open(self._aux_cache_filename)
+ f = open(self._aux_cache_filename, 'rb')
mypickle = pickle.Unpickler(f)
- mypickle.find_global = None
aux_cache = mypickle.load()
f.close()
del f
diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py
index d42b51781..89252d4b8 100644
--- a/pym/portage/getbinpkg.py
+++ b/pym/portage/getbinpkg.py
@@ -471,6 +471,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
keepconnection = 1
cache_path = "/var/cache/edb"
+ metadatafilename = os.path.join(cache_path, 'remote_metadata.pickle')
if makepickle is None:
makepickle = "/var/cache/edb/metadata.idx.most_recent"
@@ -485,7 +486,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
out = sys.stdout
try:
- metadatafile = open("/var/cache/edb/remote_metadata.pickle")
+ metadatafile = open(metadatafilename, 'rb')
metadata = pickle.load(metadatafile)
out.write("Loaded metadata pickle.\n")
out.flush()
@@ -574,7 +575,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
sys.stderr.write("!!! "+str(e)+"\n")
sys.stderr.flush()
try:
- metadatafile = open("/var/cache/edb/remote_metadata.pickle", "w+")
+ metadatafile = open(metadatafilename, 'wb')
pickle.dump(metadata,metadatafile)
metadatafile.close()
except SystemExit, e:
@@ -666,11 +667,11 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
try:
if "modified" in metadata[baseurl] and metadata[baseurl]["modified"]:
metadata[baseurl]["timestamp"] = int(time.time())
- metadatafile = open("/var/cache/edb/remote_metadata.pickle", "w+")
+ metadatafile = open(metadatafilename, 'wb')
pickle.dump(metadata,metadatafile)
metadatafile.close()
if makepickle:
- metadatafile = open(makepickle, "w")
+ metadatafile = open(makepickle, 'wb')
pickle.dump(metadata[baseurl]["data"],metadatafile)
metadatafile.close()
except SystemExit, e:
diff --git a/pym/portage/util.py b/pym/portage/util.py
index 2b5a1f214..35c4e2c0c 100644
--- a/pym/portage/util.py
+++ b/pym/portage/util.py
@@ -657,9 +657,8 @@ def pickle_read(filename,default=None,debug=0):
return default
data = None
try:
- myf = open(filename)
+ myf = open(filename, 'rb')
mypickle = pickle.Unpickler(myf)
- mypickle.find_global = None
data = mypickle.load()
myf.close()
del mypickle,myf