summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-21 14:10:42 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-21 14:10:42 (GMT)
commit14ab2776321525ac82d0ae170a5e1ab911c914c0 (patch)
treea740811e0c4169a523cf9c878927f72c3283d646 /Include
parentc4189a04a8d5fef512db33302f405c9e6170c369 (diff)
parent467ab194fc6189d9f7310c89937c51abeac56839 (diff)
downloadcpython-14ab2776321525ac82d0ae170a5e1ab911c914c0.zip
cpython-14ab2776321525ac82d0ae170a5e1ab911c914c0.tar.gz
cpython-14ab2776321525ac82d0ae170a5e1ab911c914c0.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 'Include')
-rw-r--r--Include/pyerrors.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/Include/pyerrors.h b/Include/pyerrors.h
index 03cee3d..f9f74c0 100644
--- a/Include/pyerrors.h
+++ b/Include/pyerrors.h
@@ -255,6 +255,17 @@ PyAPI_FUNC(PyObject *) PyErr_FormatV(
va_list vargs);
#endif
+#ifndef Py_LIMITED_API
+/* Like PyErr_Format(), but saves current exception as __context__ and
+ __cause__.
+ */
+PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
+ PyObject *exception,
+ const char *format, /* ASCII-encoded string */
+ ...
+ );
+#endif
+
#ifdef MS_WINDOWS
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
int ierr,