1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-12-23 22:42:52 +08:00

Only encode when output stream is binary

This commit is contained in:
Philipp Hagemeister 2012-11-27 21:07:25 +01:00
parent 95649b3936
commit c806f804d8

View File

@ -179,7 +179,7 @@ class FileDownloader(object):
if not self.params.get('quiet', False):
terminator = [u'\n', u''][skip_eol]
output = message + terminator
if 'b' not in self._screen_file.mode or sys.version_info[0] < 3: # Python 2 lies about the mode of sys.stdout/sys.stderr
if 'b' in getattr(self._screen_file, 'mode', '') or sys.version_info[0] < 3: # Python 2 lies about the mode of sys.stdout/sys.stderr
output = output.encode(preferredencoding(), 'ignore')
self._screen_file.write(output)
self._screen_file.flush()