aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/compat.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-11-15 15:17:19 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-11-15 15:17:19 +0100
commitc7b0add86f67942b8e68c1b9dd537132e9383d2f (patch)
tree64c07707f6280c1524dc029e5f46ae0c12b574c4 /youtube_dl/compat.py
parenta0155d93d9659cfc4f5f723b3e2cd7a97c0a4dc2 (diff)
[compat] Work around kwargs bugs in old 2.6 Python releases (Fixes #3813)
Diffstat (limited to 'youtube_dl/compat.py')
-rw-r--r--youtube_dl/compat.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index b3752634a..385924803 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -288,6 +288,14 @@ if sys.version_info < (3, 0) and sys.platform == 'win32':
else:
compat_getpass = getpass.getpass
+# Old 2.6 and 2.7 releases require kwargs to be bytes
+try:
+ (lambda x: x)(**{'x': 0})
+except TypeError:
+ def compat_kwargs(kwargs):
+ return dict((bytes(k), v) for k, v in kwargs.items())
+else:
+ compat_kwargs = lambda kwargs: kwargs
__all__ = [
'compat_HTTPError',
@@ -299,6 +307,7 @@ __all__ = [
'compat_html_entities',
'compat_html_parser',
'compat_http_client',
+ 'compat_kwargs',
'compat_ord',
'compat_parse_qs',
'compat_print',