Message327532
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
``` |
|
Date |
User |
Action |
Args |
2018-10-11 13:49:09 | puxlit | set | recipients:
+ puxlit |
2018-10-11 13:49:09 | puxlit | set | messageid: <1539265749.67.0.788709270274.issue34958@psf.upfronthosting.co.za> |
2018-10-11 13:49:09 | puxlit | link | issue34958 messages |
2018-10-11 13:49:09 | puxlit | create | |
|