mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-10-31 15:20:13 +00:00
python: Add special macros for error handling
Can only be used on clang or gcc but I think the library already requires them.
This commit is contained in:
parent
e044699603
commit
45318ac2e7
@ -135,3 +135,20 @@ typedef struct
|
|||||||
PyObject_HEAD;
|
PyObject_HEAD;
|
||||||
struct palette256 palette256;
|
struct palette256 palette256;
|
||||||
} Palette256Object;
|
} Palette256Object;
|
||||||
|
|
||||||
|
static inline void PyObject_cleanup(PyObject **object)
|
||||||
|
{
|
||||||
|
Py_XDECREF(*object);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CLEANUP_PY_OBJ __attribute__((cleanup(PyObject_cleanup)))
|
||||||
|
|
||||||
|
#define PY_CHECK(py_function) \
|
||||||
|
({ \
|
||||||
|
PyObject *new_object = py_function; \
|
||||||
|
if (new_object == NULL) \
|
||||||
|
{ \
|
||||||
|
return NULL; \
|
||||||
|
} \
|
||||||
|
new_object; \
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user