Victor Stinner | 23bace2 | 2019-04-18 11:37:26 +0200 | [diff] [blame] | 1 | /* |
| 2 | * C Extension module to test Python internal C APIs (Include/internal). |
| 3 | */ |
| 4 | |
| 5 | #if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE) |
| 6 | # error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined" |
| 7 | #endif |
| 8 | |
| 9 | #define PY_SSIZE_T_CLEAN |
| 10 | |
| 11 | #include "Python.h" |
Victor Stinner | 331a6a5 | 2019-05-27 16:39:22 +0200 | [diff] [blame] | 12 | #include "pycore_initconfig.h" |
Victor Stinner | 23bace2 | 2019-04-18 11:37:26 +0200 | [diff] [blame] | 13 | |
| 14 | |
| 15 | static PyObject * |
| 16 | get_configs(PyObject *self, PyObject *Py_UNUSED(args)) |
| 17 | { |
| 18 | return _Py_GetConfigsAsDict(); |
| 19 | } |
| 20 | |
| 21 | |
| 22 | static PyMethodDef TestMethods[] = { |
| 23 | {"get_configs", get_configs, METH_NOARGS}, |
| 24 | {NULL, NULL} /* sentinel */ |
| 25 | }; |
| 26 | |
| 27 | |
| 28 | static struct PyModuleDef _testcapimodule = { |
| 29 | PyModuleDef_HEAD_INIT, |
| 30 | "_testinternalcapi", |
| 31 | NULL, |
| 32 | -1, |
| 33 | TestMethods, |
| 34 | NULL, |
| 35 | NULL, |
| 36 | NULL, |
| 37 | NULL |
| 38 | }; |
| 39 | |
| 40 | |
| 41 | PyMODINIT_FUNC |
| 42 | PyInit__testinternalcapi(void) |
| 43 | { |
| 44 | return PyModule_Create(&_testcapimodule); |
| 45 | } |