diff options
author | John Zwinck <jzwinck@gmail.com> | 2020-07-21 15:50:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-21 08:50:05 +0100 |
commit | ef5656d842459a6c338ee03ee422d7bd4b8beb61 (patch) | |
tree | 70631f7198e7ae99b508fd948b4278afff16849b /numpy/array_api/tests/test_indexing_functions.py | |
parent | 2fb2c250bdfadc3a92e635e9030f9aea34c9c14e (diff) | |
download | numpy-ef5656d842459a6c338ee03ee422d7bd4b8beb61.tar.gz |
MAINT: Avoid exception in NpzFile destructor if constructor raises BadZipFile (#15604)
Previously if you gave an invalid zip file to NpzFile, zipfile_factory would raise BadZipFile and NpzFile.__exit__ would be called, which accessed members which had not yet been set, leading to a confusing second exception like this:
zipfile.BadZipFile: File is not a zip file
Exception ignored in: <function NpzFile.__del__ at 0x9b8ef0>
Traceback (most recent call last):
File "numpy/lib/npyio.py", line 230, in __del__
self.close()
File "numpy/lib/npyio.py", line 221, in close
if self.zip is not None:
AttributeError: 'NpzFile' object has no attribute 'zip'
This change makes __exit__ safe even when __init__ did not complete.
Diffstat (limited to 'numpy/array_api/tests/test_indexing_functions.py')
0 files changed, 0 insertions, 0 deletions