This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author puxlit
Recipients puxlit
Date 2018-10-11.13:49:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1539265749.67.0.788709270274.issue34958@psf.upfronthosting.co.za>
In-reply-to
Content
Following changes introduced in bpo-15002, HTTPError closes its fp when GCed via tempfile._TemporaryFileCloser's finalizer. However, the current implementation of _TemporaryFileCloser only defines __del__ for non-NT platforms.

Assuming HTTPError.fp is part of the API (though it's currently undocumented), and assuming the desired behaviour is to close fp when HTTPError is finalized, then perhaps _TemporaryFileCloser should always define __del__?

A contrived example follows:

```
from urllib.error import HTTPError
from urllib.request import urlopen

def make_request():
    try:
        urlopen('https://httpbin.org/status/418')
        assert False
    except HTTPError as err:
        assert err.code == 418
        return err.fp

fp = make_request()
assert fp.isclosed()  # Fails on Windows, passes on other platforms
```
History
Date User Action Args
2018-10-11 13:49:09puxlitsetrecipients: + puxlit
2018-10-11 13:49:09puxlitsetmessageid: <1539265749.67.0.788709270274.issue34958@psf.upfronthosting.co.za>
2018-10-11 13:49:09puxlitlinkissue34958 messages
2018-10-11 13:49:09puxlitcreate