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.

Title: zipimport: chain ImportError to OSError
Type: Stage:
Components: Versions: Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, ncoghlan, python-dev, twouters, vstinner
Priority: normal Keywords: patch

Created on 2015-03-18 00:58 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
zipimporterror_oserror.patch vstinner, 2015-03-18 00:58 review
Messages (3)
msg238368 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-03-18 00:58
To work on the issue #23694, I refactored the C function _Py_fopen_obj() to raise an exception on error. I noticed the that zipimport replaces the current exception with ZipImportError.

Attached patch chains the ZipImportError to the OSError to provide more context on error. For example, you can see in the unit test that ZipImportError was caused by a permission error.

Is it ok to require ZipImport.__context__ to be an OSError in the unit test? Can it be added to "zipimport spec"? If not, the test may be splitted to only check __context__ in a test decorated with @cpython_only.
msg238632 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-03-20 09:52
New changeset 597a87099713 by Victor Stinner in branch 'default':
Issue #23696: Chain ZipImportError to the OSError
msg238660 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-03-20 12:52
New changeset 022d64b503b8 by Victor Stinner in branch 'default':
Issue #23696: Remove test on ZipImportError.__context__ because the context is
Date User Action Args
2022-04-11 14:58:14adminsetgithub: 67884
2015-03-20 12:52:20python-devsetmessages: + msg238660
2015-03-20 09:58:49vstinnersetstatus: open -> closed
resolution: fixed
2015-03-20 09:52:34python-devsetnosy: + python-dev
messages: + msg238632
2015-03-18 13:51:18brett.cannonsetnosy: + twouters
2015-03-18 00:58:16vstinnercreate