Fix utils.is_fileobj for streaming responses from requests #805

davisp opened this Issue Jun 26, 2014 · 2 comments


None yet

3 participants

davisp commented Jun 26, 2014

Turns out that the utils.is_fileobj breaks for streamed responses from the requests library due to how we check for a fileno() function and the exception raised by urllib3.

Obvious fix is to add the IOError type to the exception list. PR to follow shortly.

@davisp davisp added the Bug label Jun 26, 2014
@davisp davisp added a commit that referenced this issue Jun 26, 2014
@davisp davisp Fix check for file-like objects
The `is_fileobject()` function in would break when the respones
was a wrapped `HTTPResponse`'s `raw` attribute. This just adds the
`IOError` exception type to the `is_fileobject()` function so that the
response can be streamed normally.

Fixes #805
@tilgovi tilgovi closed this in #806 Jun 26, 2014

This bug can still be triggered by file-like objects which wrap objects without a .fileno() method. This happened to me in combination with pyfilesystem (

The simplest fix would be to add AttributeError to the list of exceptions, just like in the commit above (fc364cc).

tilgovi commented Nov 25, 2015

@fmarczin this code isn't used anymore on master as of 6b92575. If you could reproduce problems before and can check again on master that would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment