Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Include/cpython/pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *);
PyAPI_FUNC(_PyErr_StackItem*) _PyErr_GetTopmostException(PyThreadState *tstate);
PyAPI_FUNC(void) _PyErr_GetExcInfo(PyThreadState *, PyObject **, PyObject **, PyObject **);

static inline int _PyExceptionClass_Check(PyObject *exc) {
return (PyType_Check(exc) &&
PyType_FastSubclass((PyTypeObject *)(exc), Py_TPFLAGS_BASE_EXC_SUBCLASS));
}

/* Context manipulation (PEP 3134) */

PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
Expand Down
6 changes: 1 addition & 5 deletions Include/pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ PyAPI_FUNC(void) PyException_SetCause(PyObject *, PyObject *);
PyAPI_FUNC(PyObject *) PyException_GetContext(PyObject *);
PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *);

/* */

#define PyExceptionClass_Check(x) \
(PyType_Check((x)) && \
PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))
#define PyExceptionClass_Check(exc) _PyExceptionClass_Check(_PyObject_CAST(exc))
Comment thread
erlend-aasland marked this conversation as resolved.

#define PyExceptionInstance_Check(x) \
PyType_FastSubclass(Py_TYPE(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Convert ``PyExceptionClass_Check`` from macro to static inline function.
Comment thread
erlend-aasland marked this conversation as resolved.
Outdated
Patch by Erlend E. Aasland.