diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-04-18 09:37:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-18 09:37:26 (GMT) |
commit | 23bace26ec265557697cf3b578b361c178070cd5 (patch) | |
tree | 41d99b73d99a1f8295ed6177113ed7796c8ed784 /Modules/_testinternalcapi.c | |
parent | 11efd79076559cc6e4034bb36db73e5e4293f02d (diff) | |
download | cpython-23bace26ec265557697cf3b578b361c178070cd5.zip cpython-23bace26ec265557697cf3b578b361c178070cd5.tar.gz cpython-23bace26ec265557697cf3b578b361c178070cd5.tar.bz2 |
bpo-36635: Add _testinternalcapi module (GH-12841)
Add a new _testinternalcapi module to test the internal C API.
Move _Py_GetConfigsAsDict() function to the internal C API:
_testembed now uses _testinternalcapi to access the function.
Diffstat (limited to 'Modules/_testinternalcapi.c')
-rw-r--r-- | Modules/_testinternalcapi.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c new file mode 100644 index 0000000..3a43ec1 --- /dev/null +++ b/Modules/_testinternalcapi.c @@ -0,0 +1,45 @@ +/* + * C Extension module to test Python internal C APIs (Include/internal). + */ + +#if !defined(Py_BUILD_CORE_BUILTIN) && !defined(Py_BUILD_CORE_MODULE) +# error "Py_BUILD_CORE_BUILTIN or Py_BUILD_CORE_MODULE must be defined" +#endif + +#define PY_SSIZE_T_CLEAN + +#include "Python.h" +#include "pycore_coreconfig.h" + + +static PyObject * +get_configs(PyObject *self, PyObject *Py_UNUSED(args)) +{ + return _Py_GetConfigsAsDict(); +} + + +static PyMethodDef TestMethods[] = { + {"get_configs", get_configs, METH_NOARGS}, + {NULL, NULL} /* sentinel */ +}; + + +static struct PyModuleDef _testcapimodule = { + PyModuleDef_HEAD_INIT, + "_testinternalcapi", + NULL, + -1, + TestMethods, + NULL, + NULL, + NULL, + NULL +}; + + +PyMODINIT_FUNC +PyInit__testinternalcapi(void) +{ + return PyModule_Create(&_testcapimodule); +} |