From 1494ff9dd191823015dfe03b38255dbb71c1bdeb Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 10 Dec 2009 01:04:07 +0000 Subject: 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 --- pym/_emerge/BinpkgVerifier.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'pym/_emerge/BinpkgVerifier.py') 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 -- cgit v1.2.3-1-g7c22