diff options
author | Victor Stinner <vstinner@python.org> | 2023-12-04 22:40:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-04 22:40:06 (GMT) |
commit | c5fa8a54dbdf564d482e2e3857aa3efa61edd329 (patch) | |
tree | 9ccea9297f4d21823ea5ed7fb045f1d97b3ce988 /Modules | |
parent | a8ce149628c9eaafb8c38fbf25fbd1ed483d2902 (diff) | |
download | cpython-c5fa8a54dbdf564d482e2e3857aa3efa61edd329.zip cpython-c5fa8a54dbdf564d482e2e3857aa3efa61edd329.tar.gz cpython-c5fa8a54dbdf564d482e2e3857aa3efa61edd329.tar.bz2 |
gh-112535: Add test on _Py_ThreadId() (#112709)
Add also test.support.Py_GIL_DISABLED constant.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testinternalcapi.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c index 4607a3f..ba7653f 100644 --- a/Modules/_testinternalcapi.c +++ b/Modules/_testinternalcapi.c @@ -1625,6 +1625,17 @@ get_type_module_name(PyObject *self, PyObject *type) } +#ifdef Py_GIL_DISABLED +static PyObject * +get_py_thread_id(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + uintptr_t tid = _Py_ThreadId(); + Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(tid)); + return PyLong_FromUnsignedLongLong(tid); +} +#endif + + static PyMethodDef module_functions[] = { {"get_configs", get_configs, METH_NOARGS}, {"get_recursion_depth", get_recursion_depth, METH_NOARGS}, @@ -1688,6 +1699,9 @@ static PyMethodDef module_functions[] = { {"restore_crossinterp_data", restore_crossinterp_data, METH_VARARGS}, _TESTINTERNALCAPI_TEST_LONG_NUMBITS_METHODDEF {"get_type_module_name", get_type_module_name, METH_O}, +#ifdef Py_GIL_DISABLED + {"py_thread_id", get_py_thread_id, METH_NOARGS}, +#endif {NULL, NULL} /* sentinel */ }; |