public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r12913 - in main/branches/2.1.6/pym: _emerge portage portage/dbapi
@ 2009-03-11  5:51 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-03-11  5:51 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2009-03-11 05:51:57 +0000 (Wed, 11 Mar 2009)
New Revision: 12913

Modified:
   main/branches/2.1.6/pym/_emerge/__init__.py
   main/branches/2.1.6/pym/portage/__init__.py
   main/branches/2.1.6/pym/portage/dbapi/vartree.py
   main/branches/2.1.6/pym/portage/getbinpkg.py
   main/branches/2.1.6/pym/portage/util.py
Log:
For compatibility with python-3.0, always open streams for pickles in binary
mode. (trunk r12641)


Modified: main/branches/2.1.6/pym/_emerge/__init__.py
===================================================================
--- main/branches/2.1.6/pym/_emerge/__init__.py	2009-03-11 05:48:59 UTC (rev 12912)
+++ main/branches/2.1.6/pym/_emerge/__init__.py	2009-03-11 05:51:57 UTC (rev 12913)
@@ -4027,9 +4027,8 @@
 
 	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
@@ -4113,7 +4112,7 @@
 		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(
@@ -14069,14 +14068,7 @@
 			# 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):

Modified: main/branches/2.1.6/pym/portage/__init__.py
===================================================================
--- main/branches/2.1.6/pym/portage/__init__.py	2009-03-11 05:48:59 UTC (rev 12912)
+++ main/branches/2.1.6/pym/portage/__init__.py	2009-03-11 05:51:57 UTC (rev 12913)
@@ -7426,7 +7426,7 @@
 	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)
@@ -7591,9 +7591,8 @@
 
 	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

Modified: main/branches/2.1.6/pym/portage/dbapi/vartree.py
===================================================================
--- main/branches/2.1.6/pym/portage/dbapi/vartree.py	2009-03-11 05:48:59 UTC (rev 12912)
+++ main/branches/2.1.6/pym/portage/dbapi/vartree.py	2009-03-11 05:51:57 UTC (rev 12913)
@@ -372,7 +372,7 @@
 					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(
@@ -390,9 +390,8 @@
 	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

Modified: main/branches/2.1.6/pym/portage/getbinpkg.py
===================================================================
--- main/branches/2.1.6/pym/portage/getbinpkg.py	2009-03-11 05:48:59 UTC (rev 12912)
+++ main/branches/2.1.6/pym/portage/getbinpkg.py	2009-03-11 05:51:57 UTC (rev 12913)
@@ -471,6 +471,7 @@
 		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 @@
 
 	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 @@
 					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 @@
 	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:

Modified: main/branches/2.1.6/pym/portage/util.py
===================================================================
--- main/branches/2.1.6/pym/portage/util.py	2009-03-11 05:48:59 UTC (rev 12912)
+++ main/branches/2.1.6/pym/portage/util.py	2009-03-11 05:51:57 UTC (rev 12913)
@@ -657,9 +657,8 @@
 		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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-11  5:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-11  5:51 [gentoo-commits] portage r12913 - in main/branches/2.1.6/pym: _emerge portage portage/dbapi Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox