Use codec translation finder in _util._copy_data().

testing/mmn/mktime_takes_localtime_not_gmtime
Isis Lovecruft 2013-05-22 08:00:31 +00:00
parent 5a352972b3
commit 7d1efa81f9
No known key found for this signature in database
GPG Key ID: A3ADB67A2CDB8B35
1 changed files with 2 additions and 6 deletions

View File

@ -116,11 +116,7 @@ def _copy_data(instream, outstream):
# log.exception(ae)
# return
if hasattr(sys.stdin, 'encoding'):
enc = sys.stdin.encoding
log.debug("Obtained encoding from stdin: %s" % enc)
else:
enc = 'ascii'
coder = find_encodings()
while True:
data = instream.read(1024)
@ -133,7 +129,7 @@ def _copy_data(instream, outstream):
outstream.write(data)
except UnicodeError:
try:
outstream.write(data.encode(enc))
outstream.write(coder.encode(data))
except IOError:
log.exception("Error sending data: Broken pipe")
break