Jon Dufresne added the comment: Just for some context, the e.close() is handling this bit of code:
https://github.com/python/cpython/blob/d8132c4da7c46587221c5a244224b770d03860b6/Lib/urllib/request.py#L739-L754 When there is no error, http_error_302() will close the passed fp, on error, it will not. The following comment indicates this is intentional: # Don't close the fp until we are sure that we won't use it # with HTTPError. But I agree, this may pose a problem when enforcing deterministic resource handling. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28867> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com