X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fcompat.py;h=db0da5828dd317eb5eef0b0945dec9300c7c1f75;hb=fb8bc3f81836adff9278b684b29b92d4980818f3;hp=a3a2aef53ee02a910d2357431f1c0858a5bfc15f;hpb=aa99aa4e853966d4f01e280313e3aadf2ddf7ad6;p=youtube-dl diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py index a3a2aef53..db0da5828 100644 --- a/youtube_dl/compat.py +++ b/youtube_dl/compat.py @@ -79,7 +79,9 @@ try: from urllib.parse import unquote as compat_urllib_parse_unquote from urllib.parse import unquote_plus as compat_urllib_parse_unquote_plus except ImportError: # Python 2 - # HACK: The following are the correct unquote_to_bytes and unquote + _asciire = re.compile('([\x00-\x7f]+)') if sys.version_info < (2, 7) else compat_urllib_parse._asciire + + # HACK: The following are the correct unquote_to_bytes, unquote and unquote_plus # implementations from cpython 3.4.3's stdlib. Python 2's version # is apparently broken (see https://github.com/rg3/youtube-dl/pull/6244) @@ -124,7 +126,7 @@ except ImportError: # Python 2 encoding = 'utf-8' if errors is None: errors = 'replace' - bits = compat_urllib_parse._asciire.split(string) + bits = _asciire.split(string) res = [bits[0]] append = res.append for i in range(1, len(bits), 2):