mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
gh-112535: Add test on _Py_ThreadId() (#112709)
Add also test.support.Py_GIL_DISABLED constant.
This commit is contained in:
parent
a8ce149628
commit
c5fa8a54db
6 changed files with 75 additions and 8 deletions
|
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue