aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/compat.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2018-01-23 21:53:01 +0700
committerSergey M․ <dstftw@gmail.com>2018-01-23 21:53:01 +0700
commitf206126df090d78f30426321473ebd566c3b7866 (patch)
tree9a9f745c1d8af1761e03967fd4571544f51efbfe /youtube_dl/compat.py
parent021bd012bb55da7d0be8e0ff7565d38ae17551bd (diff)
[compat] Add compat_b64decode
Diffstat (limited to 'youtube_dl/compat.py')
-rw-r--r--youtube_dl/compat.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index 41ca9adf1..646c9d79c 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -1,6 +1,7 @@
# coding: utf-8
from __future__ import unicode_literals
+import base64
import binascii
import collections
import ctypes
@@ -2908,6 +2909,16 @@ except ImportError: # not 2.6+ or is 3.x
except ImportError:
compat_zip = zip
+
+if sys.version_info < (3, 3):
+ def compat_b64decode(s, *args, **kwargs):
+ if isinstance(s, compat_str):
+ s = s.encode('ascii')
+ return base64.b64decode(s, *args, **kwargs)
+else:
+ compat_b64decode = base64.b64decode
+
+
if platform.python_implementation() == 'PyPy' and sys.pypy_version_info < (5, 4, 0):
# PyPy2 prior to version 5.4.0 expects byte strings as Windows function
# names, see the original PyPy issue [1] and the youtube-dl one [2].
@@ -2930,6 +2941,7 @@ __all__ = [
'compat_HTMLParseError',
'compat_HTMLParser',
'compat_HTTPError',
+ 'compat_b64decode',
'compat_basestring',
'compat_chr',
'compat_cookiejar',