aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2012-11-28 00:33:38 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2012-11-28 00:33:38 +0100
commit64a57846d3fe3aa919ee3539956763c8ef3211b6 (patch)
tree9d9b7f9a3049c89fc95d9beb0fbee7dc6e843110
parent72f976701a807b6d03ed7cbe59dda55218fa9c69 (diff)
correct to_stderr
-rw-r--r--youtube_dl/FileDownloader.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py
index f1931b04d..2b76a3b09 100644
--- a/youtube_dl/FileDownloader.py
+++ b/youtube_dl/FileDownloader.py
@@ -185,7 +185,10 @@ class FileDownloader(object):
def to_stderr(self, message):
"""Print message to stderr."""
assert type(message) == type(u'')
- sys.stderr.write((message + u'\n').encode(preferredencoding()))
+ output = message + u'\n'
+ 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())
+ sys.stderr.write(output)
def to_cons_title(self, message):
"""Set console/terminal window title to message."""