Commit 36aff028 authored by Christos Stavrakakis's avatar Christos Stavrakakis

Fix bug in encoding stdout

Propagate attribute access to original sys.stdout. Also fix corner case where
sys.stdout does not have encoding attribute.
parent 1cb283b9
......@@ -313,7 +313,11 @@ def configure_logging():
class EncodedStdOut(object):
def __init__(self, stdout):
self.encoding = stdout.encoding or locale.getpreferredencoding()
try:
std_encoding = stdout.encoding
except AttributeError:
std_encoding = None
self.encoding = std_encoding or locale.getpreferredencoding()
self.original_stdout = stdout
def write(self, string):
......@@ -321,6 +325,9 @@ class EncodedStdOut(object):
string = string.encode(self.encoding)
self.original_stdout.write(string)
def __getattr__(self, name):
return getattr(self.original_stdout, name)
def main():
# no need to run setup_environ
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment