Skip to content

urllib/request fails on python2 readinto  #425

Closed
@hackalog

Description

@hackalog

On Python 2, sockets don't have a readinto() method in the FP used in, for example, _safe_readinto.

leading to errors like that seen here: kivy/kivy-ios#322 (comment), or the below:

   File "/Users/hackalog/ios_demo/.buildozer/ios/platform/kivy-ios/toolchain.py", line 475, in download_file
     urlretrieve(url, filename, report_hook)
   File "/Users/hackalog/miniconda3/envs/ios_demo/lib/python2.7/site-packages/future/backports/urllib/request.py", line 1759, in retrieve
     block = fp.read(bs)
   File "/Users/hackalog/miniconda3/envs/ios_demo/lib/python2.7/site-packages/future/backports/http/client.py", line 516, in read
     return bytes(super(HTTPResponse, self).read(amt))
   File "/Users/hackalog/miniconda3/envs/ios_demo/lib/python2.7/site-packages/future/backports/http/client.py", line 545, in readinto
     return self._readinto_chunked(b)
   File "/Users/hackalog/miniconda3/envs/ios_demo/lib/python2.7/site-packages/future/backports/http/client.py", line 654, in _readinto_chunked
     n = self._safe_readinto(temp_mvb)
   File "/Users/hackalog/miniconda3/envs/ios_demo/lib/python2.7/site-packages/future/backports/http/client.py", line 701, in _safe_readinto
     n = self.fp.readinto(mvb)
 AttributeError: '_fileobject' object has no attribute 'readinto'

There's an if PY2 workaround for one of the readintocalls in client.py, but not these problematic ones. I propose a fix here: #423

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions