You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
354 B
13 lines
354 B
def is_fp_closed(obj):
|
|
"""
|
|
Checks whether a given file-like object is closed.
|
|
|
|
: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)
|
|
return obj.fp is None
|
|
|
|
return obj.closed
|
|
|