diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2014-07-24 13:29:44 +0200 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2014-07-24 13:29:44 +0200 |
commit | 4192b51c7c599d1fb1114dcee8abaa44bc48d03b (patch) | |
tree | b9b5515670bc298ee3f5b6e789e4d1b121132462 | |
parent | 052421ff0971ec3d269dc9e87e76c80dffcd2e60 (diff) |
Replace failure handling with up-front check.
The only time that write_string should fail is if the Python is completely braindead.
Check for that condition and output a more accurate warning.
See #3326 for details.
-rwxr-xr-x | youtube_dl/YoutubeDL.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 4ff1ae0e8..f295174cf 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -1234,21 +1234,18 @@ class YoutubeDL(object): if not self.params.get('verbose'): return + if type('') is not compat_str: + # Python 2.6 on SLES11 SP1 (https://github.com/rg3/youtube-dl/issues/3326) + self.report_warning( + 'Your Python is broken! Update to a newer and supported version') + encoding_str = ( '[debug] Encodings: locale %s, fs %s, out %s, pref %s\n' % ( locale.getpreferredencoding(), sys.getfilesystemencoding(), sys.stdout.encoding, 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) + write_string(encoding_str, encoding=None) self._write_string('[debug] youtube-dl version ' + __version__ + '\n') try: |