|
| 1 | +#include "parts.h" |
| 2 | +#include "util.h" |
| 3 | + |
| 4 | + |
| 5 | +static PyObject* |
| 6 | +return_string(const char *str) |
| 7 | +{ |
| 8 | + assert(str != NULL); |
| 9 | + return PyUnicode_FromString(str); |
| 10 | +} |
| 11 | + |
| 12 | + |
| 13 | +/* Test Py_GetVersion() */ |
| 14 | +static PyObject* |
| 15 | +py_getversion(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) |
| 16 | +{ |
| 17 | + return return_string(Py_GetVersion()); |
| 18 | +} |
| 19 | + |
| 20 | + |
| 21 | +/* Test Py_GetPlatform() */ |
| 22 | +static PyObject* |
| 23 | +py_getplatform(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) |
| 24 | +{ |
| 25 | + return return_string(Py_GetPlatform()); |
| 26 | +} |
| 27 | + |
| 28 | + |
| 29 | +/* Test Py_GetCopyright() */ |
| 30 | +static PyObject* |
| 31 | +py_getcopyright(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) |
| 32 | +{ |
| 33 | + return return_string(Py_GetCopyright()); |
| 34 | +} |
| 35 | + |
| 36 | + |
| 37 | +/* Test Py_GetCompiler() */ |
| 38 | +static PyObject* |
| 39 | +py_getcompiler(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) |
| 40 | +{ |
| 41 | + return return_string(Py_GetCompiler()); |
| 42 | +} |
| 43 | + |
| 44 | + |
| 45 | +/* Test Py_GetBuildInfo() */ |
| 46 | +static PyObject* |
| 47 | +py_getbuildinfo(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) |
| 48 | +{ |
| 49 | + return return_string(Py_GetBuildInfo()); |
| 50 | +} |
| 51 | + |
| 52 | + |
| 53 | +/* Test _Py_GetBuiltWithAssert() */ |
| 54 | +static PyObject* |
| 55 | +_py_getbuiltwithassert(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) |
| 56 | +{ |
| 57 | + // Function only exported for _testlimitedcapi |
| 58 | + PyAPI_FUNC(int) _Py_GetBuiltWithAssert(void); |
| 59 | + |
| 60 | + return PyLong_FromLong(_Py_GetBuiltWithAssert()); |
| 61 | +} |
| 62 | + |
| 63 | + |
| 64 | +static PyMethodDef test_methods[] = { |
| 65 | + {"py_getversion", py_getversion, METH_NOARGS}, |
| 66 | + {"py_getplatform", py_getplatform, METH_NOARGS}, |
| 67 | + {"py_getcopyright", py_getcopyright, METH_NOARGS}, |
| 68 | + {"py_getcompiler", py_getcompiler, METH_NOARGS}, |
| 69 | + {"py_getbuildinfo", py_getbuildinfo, METH_NOARGS}, |
| 70 | + {"_py_getbuiltwithassert", _py_getbuiltwithassert, METH_NOARGS}, |
| 71 | + {NULL}, |
| 72 | +}; |
| 73 | + |
| 74 | +int |
| 75 | +_PyTestLimitedCAPI_Init_Build(PyObject *m) |
| 76 | +{ |
| 77 | + return PyModule_AddFunctions(m, test_methods); |
| 78 | +} |
0 commit comments