diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2014-07-23 02:24:50 +0200 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2014-07-23 02:24:52 +0200 |
commit | b0472057a3977c6d23cb39ae645fcec17ea0f39b (patch) | |
tree | f6e601a2901f85a9d070ccf27238cb014e46d653 /youtube_dl | |
parent | c081b35c27b8e2f1735c62933709448c1a675f72 (diff) |
[YoutubeDL] Make sure we really, really get out the encoding string
Fixes #3326
Apparently, on some platforms, even outputting this fails already.
Diffstat (limited to 'youtube_dl')
-rwxr-xr-x | youtube_dl/YoutubeDL.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 686988fe5..f5ca33d45 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -1234,14 +1234,21 @@ class YoutubeDL(object): if not self.params.get('verbose'): return - write_string( + encoding_str = ( '[debug] Encodings: locale %s, fs %s, out %s, pref %s\n' % ( locale.getpreferredencoding(), sys.getfilesystemencoding(), sys.stdout.encoding, - self.get_encoding()), - encoding=None - ) + self.get_encoding())) + try: + write_string(encoding_str, encoding=None) + except: + errmsg = 'Failed to write encoding string %r' % encoding_str + try: + sys.stdout.write(errmsg) + except: + pass + raise IOError(errmsg) self._write_string('[debug] youtube-dl version ' + __version__ + '\n') try: |