diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-21 17:10:42 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-21 17:10:42 +0300 |
commit | 9cc40fa5dd2f2fd09ef70940e108211aada3be38 (patch) | |
tree | 490d255bbc4780d73142bed6b73ce65203b68648 /Include | |
parent | aeb96b1e7ff02798824876263c195cf84749bf73 (diff) | |
parent | 3888fec2a7d9d5688a9ada16652bdbc11449869f (diff) | |
download | cpython-9cc40fa5dd2f2fd09ef70940e108211aada3be38.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 'Include')
-rw-r--r-- | Include/pyerrors.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Include/pyerrors.h b/Include/pyerrors.h index 03cee3d2ba..f9f74c0ba2 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, |