Files
requests3/requests/packages/urllib3/util/response.py
T
Kevin Burke 8bbc4fcb57 Updates urllib3 to 528ad3c
This includes fixes for openssl running with Pypy, so SSL connections can be
made if ndg-httpsclient, pyopenssl and pyasn1 are installed.

see also:

- https://github.com/shazow/urllib3/issues/449
- https://github.com/pypa/pip/issues/1988
2014-08-25 13:44:29 -07:00

23 lines
566 B
Python

def is_fp_closed(obj):
"""
Checks whether a given file-like object is closed.
:param obj:
The file-like object to check.
"""
try:
# Check via the official file-like-object way.
return obj.closed
except AttributeError:
pass
try:
# Check if the object is a container for another file-like object that
# gets released on exhaustion (e.g. HTTPResponse).
return obj.fp is None
except AttributeError:
pass
raise ValueError("Unable to determine whether fp is closed.")