PyErr_SetObject: Ultimate Exception Control

This C API function offers the most flexibility, allowing developers to set an arbitrary Python object as the exception's 'value,' enabling complex error data attachment beyond simple strings.

Sources

Open the full topic