diff options
author | Petr Viktorin <encukou@gmail.com> | 2022-04-28 14:30:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-28 14:30:28 (GMT) |
commit | 6dcbc08c95cce4630b3bfb53bdb74e2523795555 (patch) | |
tree | ad1c12daa5201e81b6c68df6d46f26d8cf75688c /Modules | |
parent | d1de10784d9678d14759d0d03216431d1090e60e (diff) | |
download | cpython-6dcbc08c95cce4630b3bfb53bdb74e2523795555.zip cpython-6dcbc08c95cce4630b3bfb53bdb74e2523795555.tar.gz cpython-6dcbc08c95cce4630b3bfb53bdb74e2523795555.tar.bz2 |
gh-91324: List feature macros in the stable ABI manifest, improve tests (GH-32415)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapi_feature_macros.inc | 49 | ||||
-rw-r--r-- | Modules/_testcapimodule.c | 13 |
2 files changed, 62 insertions, 0 deletions
diff --git a/Modules/_testcapi_feature_macros.inc b/Modules/_testcapi_feature_macros.inc new file mode 100644 index 0000000..b1763b5 --- /dev/null +++ b/Modules/_testcapi_feature_macros.inc @@ -0,0 +1,49 @@ +// Generated by Tools/scripts/stable_abi.py + +// Add an entry in dict `result` for each Stable ABI feature macro. + +#ifdef HAVE_FORK + res = PyDict_SetItemString(result, "HAVE_FORK", Py_True); +#else + res = PyDict_SetItemString(result, "HAVE_FORK", Py_False); +#endif +if (res) { + Py_DECREF(result); return NULL; +} + +#ifdef MS_WINDOWS + res = PyDict_SetItemString(result, "MS_WINDOWS", Py_True); +#else + res = PyDict_SetItemString(result, "MS_WINDOWS", Py_False); +#endif +if (res) { + Py_DECREF(result); return NULL; +} + +#ifdef PY_HAVE_THREAD_NATIVE_ID + res = PyDict_SetItemString(result, "PY_HAVE_THREAD_NATIVE_ID", Py_True); +#else + res = PyDict_SetItemString(result, "PY_HAVE_THREAD_NATIVE_ID", Py_False); +#endif +if (res) { + Py_DECREF(result); return NULL; +} + +#ifdef Py_REF_DEBUG + res = PyDict_SetItemString(result, "Py_REF_DEBUG", Py_True); +#else + res = PyDict_SetItemString(result, "Py_REF_DEBUG", Py_False); +#endif +if (res) { + Py_DECREF(result); return NULL; +} + +#ifdef USE_STACKCHECK + res = PyDict_SetItemString(result, "USE_STACKCHECK", Py_True); +#else + res = PyDict_SetItemString(result, "USE_STACKCHECK", Py_False); +#endif +if (res) { + Py_DECREF(result); return NULL; +} + diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 6bd73e8..9073f33 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -5919,6 +5919,18 @@ frame_getlasti(PyObject *self, PyObject *frame) return PyLong_FromLong(lasti); } +static PyObject * +get_feature_macros(PyObject *self, PyObject *Py_UNUSED(args)) +{ + PyObject *result = PyDict_New(); + if (!result) { + return NULL; + } + int res; +#include "_testcapi_feature_macros.inc" + return result; +} + static PyObject *negative_dictoffset(PyObject *, PyObject *); static PyObject *test_buildvalue_issue38913(PyObject *, PyObject *); @@ -6214,6 +6226,7 @@ static PyMethodDef TestMethods[] = { {"frame_getgenerator", frame_getgenerator, METH_O, NULL}, {"frame_getbuiltins", frame_getbuiltins, METH_O, NULL}, {"frame_getlasti", frame_getlasti, METH_O, NULL}, + {"get_feature_macros", get_feature_macros, METH_NOARGS, NULL}, {NULL, NULL} /* sentinel */ }; |