mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-111696, PEP 737: Add PyType_GetModuleName() function (#116824)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
This commit is contained in:
parent
25cd8730aa
commit
c432df6d56
15 changed files with 48 additions and 27 deletions
|
|
@ -402,7 +402,7 @@ partial_repr(partialobject *pto)
|
|||
goto done;
|
||||
}
|
||||
|
||||
mod = _PyType_GetModuleName(Py_TYPE(pto));
|
||||
mod = PyType_GetModuleName(Py_TYPE(pto));
|
||||
if (mod == NULL) {
|
||||
goto error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -622,6 +622,14 @@ get_type_fullyqualname(PyObject *self, PyObject *type)
|
|||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
get_type_module_name(PyObject *self, PyObject *type)
|
||||
{
|
||||
assert(PyType_Check(type));
|
||||
return PyType_GetModuleName((PyTypeObject *)type);
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
test_get_type_dict(PyObject *self, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
|
|
@ -3268,6 +3276,7 @@ static PyMethodDef TestMethods[] = {
|
|||
{"get_type_name", get_type_name, METH_O},
|
||||
{"get_type_qualname", get_type_qualname, METH_O},
|
||||
{"get_type_fullyqualname", get_type_fullyqualname, METH_O},
|
||||
{"get_type_module_name", get_type_module_name, METH_O},
|
||||
{"test_get_type_dict", test_get_type_dict, METH_NOARGS},
|
||||
{"_test_thread_state", test_thread_state, METH_VARARGS},
|
||||
#ifndef MS_WINDOWS
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include "pycore_pathconfig.h" // _PyPathConfig_ClearGlobal()
|
||||
#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
|
||||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||
#include "pycore_typeobject.h" // _PyType_GetModuleName()
|
||||
|
||||
#include "interpreteridobject.h" // PyInterpreterID_LookUp()
|
||||
|
||||
|
|
@ -1631,13 +1630,6 @@ perf_trampoline_set_persist_after_fork(PyObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
get_type_module_name(PyObject *self, PyObject *type)
|
||||
{
|
||||
assert(PyType_Check(type));
|
||||
return _PyType_GetModuleName((PyTypeObject *)type);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
get_rare_event_counters(PyObject *self, PyObject *type)
|
||||
{
|
||||
|
|
@ -1741,7 +1733,6 @@ static PyMethodDef module_functions[] = {
|
|||
{"get_crossinterp_data", get_crossinterp_data, METH_VARARGS},
|
||||
{"restore_crossinterp_data", restore_crossinterp_data, METH_VARARGS},
|
||||
_TESTINTERNALCAPI_TEST_LONG_NUMBITS_METHODDEF
|
||||
{"get_type_module_name", get_type_module_name, METH_O},
|
||||
{"get_rare_event_counters", get_rare_event_counters, METH_NOARGS},
|
||||
{"reset_rare_event_counters", reset_rare_event_counters, METH_NOARGS},
|
||||
#ifdef Py_GIL_DISABLED
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue