(Merge 3.2) Handle correctly _Py_fopen() error: don't replace the exception
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index ed835c9..09bd83a 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -742,7 +742,8 @@
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 @@
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;
}