diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-18 00:39:23 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-18 00:39:23 (GMT) |
commit | e42ccd2bfd7a05a02c1020b819e4ee5b26041d01 (patch) | |
tree | 071843848770176c8aed3f965d783738182847c3 /Modules/zipimport.c | |
parent | a555cfcb73cf677a99d29af6fa0bcfe4c35a2aeb (diff) | |
download | cpython-e42ccd2bfd7a05a02c1020b819e4ee5b26041d01.zip cpython-e42ccd2bfd7a05a02c1020b819e4ee5b26041d01.tar.gz cpython-e42ccd2bfd7a05a02c1020b819e4ee5b26041d01.tar.bz2 |
Issue #23694: Enhance _Py_fopen(), it now raises an exception on error
* If fopen() fails, OSError is raised with the original filename object.
* The GIL is now released while calling fopen()
Diffstat (limited to 'Modules/zipimport.c')
-rw-r--r-- | Modules/zipimport.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Modules/zipimport.c b/Modules/zipimport.c index f2cc245..f5ac10b 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -875,7 +875,7 @@ read_directory(PyObject *archive) fp = _Py_fopen_obj(archive, "rb"); if (fp == NULL) { - if (!PyErr_Occurred()) + if (PyErr_ExceptionMatches(PyExc_OSError)) PyErr_Format(ZipImportError, "can't open Zip file: %R", archive); return NULL; } @@ -1073,12 +1073,8 @@ get_data(PyObject *archive, PyObject *toc_entry) } fp = _Py_fopen_obj(archive, "rb"); - if (!fp) { - if (!PyErr_Occurred()) - PyErr_Format(PyExc_IOError, - "zipimport: can not open file %U", archive); + if (!fp) return NULL; - } /* Check to make sure the local file header is correct */ if (fseek(fp, file_offset, 0) == -1) { |