mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Issue #28410: Added _PyErr_FormatFromCause() -- the helper for raising
new exception with setting current exception as __cause__. _PyErr_FormatFromCause(exception, format, args...) is equivalent to Python raise exception(format % args) from sys.exc_info()[1]
This commit is contained in:
parent
b0426cd8c4
commit
467ab194fc
7 changed files with 70 additions and 53 deletions
|
@ -907,10 +907,8 @@ read_directory(PyObject *archive)
|
|||
fp = _Py_fopen_obj(archive, "rb");
|
||||
if (fp == NULL) {
|
||||
if (PyErr_ExceptionMatches(PyExc_OSError)) {
|
||||
PyObject *exc, *val, *tb;
|
||||
PyErr_Fetch(&exc, &val, &tb);
|
||||
PyErr_Format(ZipImportError, "can't open Zip file: %R", archive);
|
||||
_PyErr_ChainExceptions(exc, val, tb);
|
||||
_PyErr_FormatFromCause(ZipImportError,
|
||||
"can't open Zip file: %R", archive);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue