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
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(
# 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):
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)
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
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(
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
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"
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()
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:
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:
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