]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Handle correctly _Py_fopen() error: don't replace the exception
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 18 Dec 2011 20:04:17 +0000 (21:04 +0100)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 18 Dec 2011 20:04:17 +0000 (21:04 +0100)
Modules/zipimport.c

index 68c2894fbe111f758b3b8b72eb8b36bfd673b998..11c390452538b8f53cfac15e7a8bf3416f6de695 100644 (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;
     }