summaryrefslogtreecommitdiff
path: root/Modules/zipimport.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-21 17:09:17 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-21 17:09:17 +0300
commit3888fec2a7d9d5688a9ada16652bdbc11449869f (patch)
tree8ead00f16c8e705b0034c489ccff09bc0b2ccb23 /Modules/zipimport.c
parent0da06101a0e93a86d1fb10cb4edf2c6552d7e523 (diff)
downloadcpython-3888fec2a7d9d5688a9ada16652bdbc11449869f.tar.gz
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]
Diffstat (limited to 'Modules/zipimport.c')
-rw-r--r--Modules/zipimport.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index 7473a8fe87..59046aaae4 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -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;
}