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

This commit is contained in:
Victor Stinner 2011-12-18 21:05:22 +01:00
commit 3573476271
2 changed files with 26 additions and 12 deletions

View file

@ -742,7 +742,8 @@ read_directory(PyObject *archive)
fp = _Py_fopen(archive, "rb");
if (fp == NULL) {
PyErr_Format(ZipImportError, "can't open Zip file: %R", archive);
if (!PyErr_Occurred())
PyErr_Format(ZipImportError, "can't open Zip file: %R", archive);
return NULL;
}
fseek(fp, -22, SEEK_END);
@ -913,8 +914,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;
}