mirror of
https://github.com/python/cpython
synced 2026-09-29 09:55:31 +03:00
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()
This commit is contained in:
parent
a555cfcb73
commit
e42ccd2bfd
5 changed files with 44 additions and 24 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue