]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
CurlAsyncHTTPClient: remove ubuntu-12.10 python3 fix 2402/head
authorPierce Lopez <pierce.lopez@gmail.com>
Thu, 24 May 2018 15:48:38 +0000 (11:48 -0400)
committerPierce Lopez <pierce.lopez@gmail.com>
Thu, 24 May 2018 15:48:38 +0000 (11:48 -0400)
No need to utf8() what is passed to WRITEFUNCTION, it will always
be bytes on python3 for upstream pycurl on python3.
The ubuntu-12.10 variant is long gone.

tornado/curl_httpclient.py

index ef98225cb95c12b1c8f8efcb8733f834ee010972..2edbca367d554ca07e88a33aa3c355e46f96fe18 100644 (file)
@@ -319,17 +319,7 @@ class CurlAsyncHTTPClient(AsyncHTTPClient):
                 self.io_loop.add_callback(request.streaming_callback, chunk)
         else:
             write_function = buffer.write
-        if bytes is str:  # py2
-            curl.setopt(pycurl.WRITEFUNCTION, write_function)
-        else:  # py3
-            # Upstream pycurl doesn't support py3, but ubuntu 12.10 includes
-            # a fork/port.  That version has a bug in which it passes unicode
-            # strings instead of bytes to the WRITEFUNCTION.  This means that
-            # if you use a WRITEFUNCTION (which tornado always does), you cannot
-            # download arbitrary binary data.  This needs to be fixed in the
-            # ported pycurl package, but in the meantime this lambda will
-            # make it work for downloading (utf8) text.
-            curl.setopt(pycurl.WRITEFUNCTION, lambda s: write_function(utf8(s)))
+        curl.setopt(pycurl.WRITEFUNCTION, write_function)
         curl.setopt(pycurl.FOLLOWLOCATION, request.follow_redirects)
         curl.setopt(pycurl.MAXREDIRS, request.max_redirects)
         curl.setopt(pycurl.CONNECTTIMEOUT_MS, int(1000 * request.connect_timeout))