summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-12-08 23:47:38 +0000
committerZac Medico <zmedico@gentoo.org>2009-12-08 23:47:38 +0000
commit27783e3125348e8cd147c438b534c246eedf38c2 (patch)
treeeb76deedd294ed116a15f27cd1e4a233084e587e /pym/_emerge/BinpkgVerifier.py
parentDon't assign f to sys.stderr inside EOutput._write(). (diff)
downloadportage-idfetch-27783e3125348e8cd147c438b534c246eedf38c2.tar.gz
portage-idfetch-27783e3125348e8cd147c438b534c246eedf38c2.tar.bz2
portage-idfetch-27783e3125348e8cd147c438b534c246eedf38c2.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). svn path=/main/trunk/; revision=14971
Diffstat (limited to 'pym/_emerge/BinpkgVerifier.py')
-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 d3695871..0283883c 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