mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Add Modules/_testcapi/util.h header (GH-108774)
It contains common macros used in C API tests.
This commit is contained in:
parent
578ebc5d5f
commit
0e01fac315
7 changed files with 49 additions and 94 deletions
|
|
@ -43,16 +43,8 @@
|
|||
// Several parts of this module are broken out into files in _testcapi/.
|
||||
// Include definitions from there.
|
||||
#include "_testcapi/parts.h"
|
||||
#include "_testcapi/util.h"
|
||||
|
||||
#define NULLABLE(x) do { if (x == Py_None) x = NULL; } while (0);
|
||||
|
||||
#define RETURN_INT(value) do { \
|
||||
int _ret = (value); \
|
||||
if (_ret == -1) { \
|
||||
return NULL; \
|
||||
} \
|
||||
return PyLong_FromLong(_ret); \
|
||||
} while (0)
|
||||
|
||||
// Forward declarations
|
||||
static struct PyModuleDef _testcapimodule;
|
||||
|
|
@ -1333,19 +1325,13 @@ static PyObject *
|
|||
test_PyBuffer_SizeFromFormat(PyObject *self, PyObject *args)
|
||||
{
|
||||
const char *format;
|
||||
Py_ssize_t result;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:test_PyBuffer_SizeFromFormat",
|
||||
&format)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = PyBuffer_SizeFromFormat(format);
|
||||
if (result == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyLong_FromSsize_t(result);
|
||||
RETURN_SIZE(PyBuffer_SizeFromFormat(format));
|
||||
}
|
||||
|
||||
/* Test that the fatal error from not having a current thread doesn't
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue