summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-12-10 01:04:07 +0000
committerZac Medico <zmedico@gentoo.org>2009-12-10 01:04:07 +0000
commit1494ff9dd191823015dfe03b38255dbb71c1bdeb (patch)
treef4fbe520c6769ebb1a6dc6d9518570f87d2f8849
parent067ddb05396ba7e288e0acfa4e9631d55bfcc691 (diff)
downloadportage-1494ff9dd191823015dfe03b38255dbb71c1bdeb.tar.gz
portage-1494ff9dd191823015dfe03b38255dbb71c1bdeb.tar.bz2
portage-1494ff9dd191823015dfe03b38255dbb71c1bdeb.zip
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) svn path=/main/branches/2.1.7/; revision=15005
-rw-r--r--pym/_emerge/BinpkgVerifier.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/pym/_emerge/BinpkgVerifier.py b/pym/_emerge/BinpkgVerifier.py
index d36958717..0283883c1 100644
--- a/pym/_emerge/BinpkgVerifier.py
+++ b/pym/_emerge/BinpkgVerifier.py
@@ -29,9 +29,19 @@ class BinpkgVerifier(AsynchronousTask):
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