[issue44938] Expose PyErr_ChainExceptions in the stable API

Serhiy Storchaka report at bugs.python.org
Wed Aug 18 00:09:59 EDT 2021


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

As the original author of _PyErr_ChainExceptions() (issue21715) I am not sure that its name and signature are optimal. It did not matter while it was internal function because we could change them at any moment, but for public API the design should be more thoughtful.

Is passing three arguments convenient enough? Would not be better to pass them as a single argument like in _PyErr_ChainStackItem()? Is the function name good? Should we provide several similar functions for setting __context__, __cause__ and both?

There are other, more specialized, helpers: _PyErr_FormatFromCause() and _PyErr_TrySetFromCause().

There are also some flaws in setting __context__ and __cause__ (see issue39725). Perhaps we will design better concept of chaining exceptions in future.

----------
components: +C API
nosy: +serhiy.storchaka
type:  -> enhancement
versions: +Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44938>
_______________________________________


More information about the Python-bugs-list mailing list