about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2020-05-05 05:54:10 +0700
committerSergey M․ <dstftw@gmail.com>2020-05-05 05:54:10 +0700
commit6d874fee2a4b54272c48960f3082072d37a7e0ae (patch)
tree81eb6c791bc48d75b9dc13701aee43b096a24259
parent676723e0daf86eafb31d82ba07813ebc98b334dd (diff)
downloadyoutube-dl-6d874fee2a4b54272c48960f3082072d37a7e0ae.tar.gz
youtube-dl-6d874fee2a4b54272c48960f3082072d37a7e0ae.tar.xz
youtube-dl-6d874fee2a4b54272c48960f3082072d37a7e0ae.zip
[compat] Introduce compat_cookiejar_Cookie
-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 d1b86bd13..0ee9bc760 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -57,6 +57,17 @@ try:
 except ImportError:  # Python 2
     import cookielib as compat_cookiejar
 
+if sys.version_info[0] == 2:
+    class compat_cookiejar_Cookie(compat_cookiejar.Cookie):
+        def __init__(self, version, name, value, *args, **kwargs):
+            if isinstance(name, compat_str):
+                name = name.encode()
+            if isinstance(value, compat_str):
+                value = value.encode()
+            compat_cookiejar.Cookie.__init__(self, version, name, value, *args, **kwargs)
+else:
+    compat_cookiejar_Cookie = compat_cookiejar.Cookie
+
 try:
     import http.cookies as compat_cookies
 except ImportError:  # Python 2
@@ -2987,6 +2998,7 @@ __all__ = [
     'compat_basestring',
     'compat_chr',
     'compat_cookiejar',
+    'compat_cookiejar_Cookie',
     'compat_cookies',
     'compat_ctypes_WINFUNCTYPE',
     'compat_etree_Element',