diff options
author | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 13:41:34 -0700 |
---|---|---|
committer | SVN-Git Migration <python-modules-team@lists.alioth.debian.org> | 2015-10-08 13:41:34 -0700 |
commit | 2c79b40c98c83e352c5479223d581d69b0e7806c (patch) | |
tree | 81c85525061fbc4805ff2ec2280f560956c35d64 /requests/packages/urllib3/util/response.py | |
parent | d075cc8a1294c77c994dc5fd220ecb163ed31b93 (diff) | |
download | python-requests-2c79b40c98c83e352c5479223d581d69b0e7806c.tar python-requests-2c79b40c98c83e352c5479223d581d69b0e7806c.tar.gz |
Imported Upstream version 2.4.3
Diffstat (limited to 'requests/packages/urllib3/util/response.py')
-rw-r--r-- | requests/packages/urllib3/util/response.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/requests/packages/urllib3/util/response.py b/requests/packages/urllib3/util/response.py index d0325bc..45fff55 100644 --- a/requests/packages/urllib3/util/response.py +++ b/requests/packages/urllib3/util/response.py @@ -5,9 +5,18 @@ def is_fp_closed(obj): :param obj: The file-like object to check. """ - if hasattr(obj, 'fp'): - # Object is a container for another file-like object that gets released - # on exhaustion (e.g. HTTPResponse) + + 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 - return obj.closed + raise ValueError("Unable to determine whether fp is closed.") |