cpython/Modules/_testcapi/util.h
Serhiy Storchaka 0e01fac315
Add Modules/_testcapi/util.h header (GH-108774)
It contains common macros used in C API tests.
2023-09-01 21:42:42 +03:00

25 lines
971 B
C

#define NULLABLE(x) do { \
if (x == Py_None) { \
x = NULL; \
} \
} while (0);
#define RETURN_INT(value) do { \
int _ret = (value); \
if (_ret == -1) { \
assert(PyErr_Occurred()); \
return NULL; \
} \
assert(!PyErr_Occurred()); \
return PyLong_FromLong(_ret); \
} while (0)
#define RETURN_SIZE(value) do { \
Py_ssize_t _ret = (value); \
if (_ret == -1) { \
assert(PyErr_Occurred()); \
return NULL; \
} \
assert(!PyErr_Occurred()); \
return PyLong_FromSsize_t(_ret); \
} while (0)