aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/compat.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-07-18 00:24:39 +0600
committerSergey M․ <dstftw@gmail.com>2015-07-18 00:24:39 +0600
commit3cc8b4c327585ff4dbb045d17d6f5c160df6fdb8 (patch)
tree615459624fd215ba2356f9a39e600ec403b5e5e7 /youtube_dl/compat.py
parent6b19647d5706b75b5e2d7da836495fe5174919f4 (diff)
[compat] Fix missing _asciire on python 2.6
Diffstat (limited to 'youtube_dl/compat.py')
-rw-r--r--youtube_dl/compat.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index e950a4688..db0da5828 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -79,6 +79,8 @@ 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
+ _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):