Handle correctly _Py_fopen() error: don't replace the exception

This commit is contained in:
Victor Stinner 2011-12-18 21:04:17 +01:00
parent 165b1283ff
commit bd206e27a4
1 changed files with 5 additions and 3 deletions

View File

@ -736,7 +736,8 @@ read_directory(PyObject *archive_obj)
fp = _Py_fopen(archive_obj, "rb");
if (fp == NULL) {
PyErr_Format(ZipImportError, "can't open Zip file: '%U'", archive_obj);
if (!PyErr_Occurred())
PyErr_Format(ZipImportError, "can't open Zip file: '%U'", archive_obj);
return NULL;
}
fseek(fp, -22, SEEK_END);
@ -909,8 +910,9 @@ get_data(PyObject *archive, PyObject *toc_entry)
fp = _Py_fopen(archive, "rb");
if (!fp) {
PyErr_Format(PyExc_IOError,
"zipimport: can not open file %U", archive);
if (!PyErr_Occurred())
PyErr_Format(PyExc_IOError,
"zipimport: can not open file %U", archive);
return NULL;
}