summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-21 14:09:17 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-21 14:09:17 (GMT)
commit467ab194fc6189d9f7310c89937c51abeac56839 (patch)
treeac2397959d646b3656fbf4759f4e6cb9d82e4ae6 /Objects/abstract.c
parentb0426cd8c4ecaa19cff05b4860da1c06531a77c1 (diff)
downloadcpython-467ab194fc6189d9f7310c89937c51abeac56839.zip
cpython-467ab194fc6189d9f7310c89937c51abeac56839.tar.gz
cpython-467ab194fc6189d9f7310c89937c51abeac56839.tar.bz2
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 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 747eda0..f9afece 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2198,20 +2198,18 @@ _Py_CheckFunctionResult(PyObject *func, PyObject *result, const char *where)
}
else {
if (err_occurred) {
- PyObject *exc, *val, *tb;
- PyErr_Fetch(&exc, &val, &tb);
-
Py_DECREF(result);
- if (func)
- PyErr_Format(PyExc_SystemError,
- "%R returned a result with an error set",
- func);
- else
- PyErr_Format(PyExc_SystemError,
- "%s returned a result with an error set",
- where);
- _PyErr_ChainExceptions(exc, val, tb);
+ if (func) {
+ _PyErr_FormatFromCause(PyExc_SystemError,
+ "%R returned a result with an error set",
+ func);
+ }
+ else {
+ _PyErr_FormatFromCause(PyExc_SystemError,
+ "%s returned a result with an error set",
+ where);
+ }
#ifdef Py_DEBUG
/* Ensure that the bug is caught in debug mode */
Py_FatalError("a function returned a result with an error set");