Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd206e2

Browse files
author
Victor Stinner
committed
Handle correctly _Py_fopen() error: don't replace the exception
1 parent 165b128 commit bd206e2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Modules/zipimport.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,8 @@ read_directory(PyObject *archive_obj)
736736

737737
fp = _Py_fopen(archive_obj, "rb");
738738
if (fp == NULL) {
739-
PyErr_Format(ZipImportError, "can't open Zip file: '%U'", archive_obj);
739+
if (!PyErr_Occurred())
740+
PyErr_Format(ZipImportError, "can't open Zip file: '%U'", archive_obj);
740741
return NULL;
741742
}
742743
fseek(fp, -22, SEEK_END);
@@ -909,8 +910,9 @@ get_data(PyObject *archive, PyObject *toc_entry)
909910

910911
fp = _Py_fopen(archive, "rb");
911912
if (!fp) {
912-
PyErr_Format(PyExc_IOError,
913-
"zipimport: can not open file %U", archive);
913+
if (!PyErr_Occurred())
914+
PyErr_Format(PyExc_IOError,
915+
"zipimport: can not open file %U", archive);
914916
return NULL;
915917
}
916918

0 commit comments

Comments
 (0)