From: Victor Stinner Date: Sun, 18 Dec 2011 20:04:17 +0000 (+0100) Subject: Handle correctly _Py_fopen() error: don't replace the exception X-Git-Tag: v3.2.3rc1~268 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bd206e27a49dd4cc94ee264c706614190ce0eb3c;p=thirdparty%2FPython%2Fcpython.git Handle correctly _Py_fopen() error: don't replace the exception --- diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 68c2894fbe11..11c390452538 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -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; }