public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r15005 - main/branches/2.1.7/pym/_emerge
@ 2009-12-10  1:04 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-12-10  1:04 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2009-12-10 01:04:07 +0000 (Thu, 10 Dec 2009)
New Revision: 15005

Modified:
   main/branches/2.1.7/pym/_emerge/BinpkgVerifier.py
Log:
When temporarily replacing the sys.std* streams, use the normal open() func
in python3 so that we get the right class (otherwise our code that expects
the 'buffer' attribute will break). (trunk r14971)

Modified: main/branches/2.1.7/pym/_emerge/BinpkgVerifier.py
===================================================================
--- main/branches/2.1.7/pym/_emerge/BinpkgVerifier.py	2009-12-10 01:03:58 UTC (rev 15004)
+++ main/branches/2.1.7/pym/_emerge/BinpkgVerifier.py	2009-12-10 01:04:07 UTC (rev 15005)
@@ -29,9 +29,19 @@
 		stderr_orig = sys.stderr
 		log_file = None
 		if self.background and self.logfile is not None:
-			log_file = codecs.open(_unicode_encode(self.logfile,
-			encoding=_encodings['fs'], errors='strict'),
-				mode='a', encoding=_encodings['content'], errors='replace')
+			if sys.hexversion >= 0x3000000:
+				# Since we are replacing the sys.std* streams,
+				# we need to use the normal open() function
+				# so that we get the right class (otherwise our
+				# code that expects the 'buffer' attribute
+				# will break).
+				open_func = open
+			else:
+				open_func = codecs.open
+			log_file = open_func(_unicode_encode(self.logfile,
+				encoding=_encodings['fs'], errors='strict'),
+				mode='a', encoding=_encodings['content'],
+				errors='backslashreplace')
 		try:
 			if log_file is not None:
 				sys.stdout = log_file




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

only message in thread, other threads:[~2009-12-10  1:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-10  1:04 [gentoo-commits] portage r15005 - main/branches/2.1.7/pym/_emerge 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