mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 09:17:48 +00:00
[extractor/common] Properly decode error string on python 2 (Closes #1354, closes #3957, closes #4037, closes #6449)
This commit is contained in:
parent
fa64a84311
commit
dd85e4d707
1 changed files with 7 additions and 1 deletions
|
@ -34,6 +34,7 @@ from ..utils import (
|
||||||
fix_xml_ampersands,
|
fix_xml_ampersands,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
preferredencoding,
|
||||||
RegexNotFoundError,
|
RegexNotFoundError,
|
||||||
sanitize_filename,
|
sanitize_filename,
|
||||||
sanitized_Request,
|
sanitized_Request,
|
||||||
|
@ -332,7 +333,12 @@ class InfoExtractor(object):
|
||||||
return False
|
return False
|
||||||
if errnote is None:
|
if errnote is None:
|
||||||
errnote = 'Unable to download webpage'
|
errnote = 'Unable to download webpage'
|
||||||
errmsg = '%s: %s' % (errnote, compat_str(err))
|
err_str = str(err)
|
||||||
|
# On python 2 error byte string must be decoded with proper
|
||||||
|
# encoding rather than ascii
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
err_str = err_str.decode(preferredencoding())
|
||||||
|
errmsg = '%s: %s' % (errnote, err_str)
|
||||||
if fatal:
|
if fatal:
|
||||||
raise ExtractorError(errmsg, sys.exc_info()[2], cause=err)
|
raise ExtractorError(errmsg, sys.exc_info()[2], cause=err)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue