summary refs log tree commit diff
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2017-05-27 23:05:02 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2017-05-27 23:05:02 +0800
commitb407d8533d3956a7c27ad42cbde9a877c36df72c (patch)
treefdb0cfcd2c02fdec24000c1ae459aaabb72d2c93
parent20e2c9de0414f18dff26020045445cf91cad6b70 (diff)
downloadyoutube-dl-b407d8533d3956a7c27ad42cbde9a877c36df72c.tar.gz
youtube-dl-b407d8533d3956a7c27ad42cbde9a877c36df72c.tar.xz
youtube-dl-b407d8533d3956a7c27ad42cbde9a877c36df72c.zip
[utils] Drop an compatibility wrapper for Python < 2.6
addinfourl.getcode is added since Python 2.6a1. As youtube-dl now
requires 2.6+, this is no longer necessary.

See https://github.com/python/cpython/commit/9b0d46db115c10767b240a0a64286214b50fe6ad
-rw-r--r--youtube_dl/utils.py12
1 files changed, 2 insertions, 10 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 6c84bfe0f..d79410e58 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -932,14 +932,6 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
         except zlib.error:
             return zlib.decompress(data)
 
-    @staticmethod
-    def addinfourl_wrapper(stream, headers, url, code):
-        if hasattr(compat_urllib_request.addinfourl, 'getcode'):
-            return compat_urllib_request.addinfourl(stream, headers, url, code)
-        ret = compat_urllib_request.addinfourl(stream, headers, url)
-        ret.code = code
-        return ret
-
     def http_request(self, req):
         # According to RFC 3986, URLs can not contain non-ASCII characters, however this is not
         # always respected by websites, some tend to give out URLs with non percent-encoded
@@ -991,13 +983,13 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
                     break
                 else:
                     raise original_ioerror
-            resp = self.addinfourl_wrapper(uncompressed, old_resp.headers, old_resp.url, old_resp.code)
+            resp = compat_urllib_request.addinfourl(uncompressed, old_resp.headers, old_resp.url, old_resp.code)
             resp.msg = old_resp.msg
             del resp.headers['Content-encoding']
         # deflate
         if resp.headers.get('Content-encoding', '') == 'deflate':
             gz = io.BytesIO(self.deflate(resp.read()))
-            resp = self.addinfourl_wrapper(gz, old_resp.headers, old_resp.url, old_resp.code)
+            resp = compat_urllib_request.addinfourl(gz, old_resp.headers, old_resp.url, old_resp.code)
             resp.msg = old_resp.msg
             del resp.headers['Content-encoding']
         # Percent-encode redirect URL of Location HTTP header to satisfy RFC 3986 (see