Improve addinfourl_wrapper for compatibility with older Python versions
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>
Thu, 20 Jan 2011 19:36:42 +0000 (20:36 +0100)
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>
Thu, 20 Jan 2011 19:36:42 +0000 (20:36 +0100)
youtube-dl

index 1b20025e7d7ea91da1e3d9fccfe6d5a56e2c4b29..103189b21f1c317e058e91fa3f8a02056f6c70f1 100755 (executable)
@@ -193,7 +193,9 @@ class YoutubeDLHandler(urllib2.HTTPHandler):
        def addinfourl_wrapper(stream, headers, url, code):
                if hasattr(urllib2.addinfourl, 'getcode'):
                        return urllib2.addinfourl(stream, headers, url, code)
-               return urllib2.addinfourl(stream, headers, url)
+               ret = urllib2.addinfourl(stream, headers, url)
+               ret.code = code
+               return ret
        
        def http_request(self, req):
                for h in std_headers: