mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-140550: Initial implementation of PEP 793 – PyModExport (GH-140556)
Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
parent
f2bce51b98
commit
589a03a8ce
32 changed files with 1494 additions and 236 deletions
|
|
@ -5764,11 +5764,11 @@ PyType_GetModuleState(PyTypeObject *type)
|
|||
}
|
||||
|
||||
|
||||
/* Get the module of the first superclass where the module has the
|
||||
* given PyModuleDef.
|
||||
/* Return borrowed ref to the module of the first superclass where the module
|
||||
* has the given token.
|
||||
*/
|
||||
PyObject *
|
||||
PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
|
||||
static PyObject *
|
||||
borrow_module_by_token(PyTypeObject *type, const void *token)
|
||||
{
|
||||
assert(PyType_Check(type));
|
||||
|
||||
|
|
@ -5780,7 +5780,7 @@ PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
|
|||
else {
|
||||
PyHeapTypeObject *ht = (PyHeapTypeObject*)type;
|
||||
PyObject *module = ht->ht_module;
|
||||
if (module && _PyModule_GetDef(module) == def) {
|
||||
if (module && _PyModule_GetToken(module) == token) {
|
||||
return module;
|
||||
}
|
||||
}
|
||||
|
|
@ -5808,7 +5808,7 @@ PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
|
|||
|
||||
PyHeapTypeObject *ht = (PyHeapTypeObject*)super;
|
||||
PyObject *module = ht->ht_module;
|
||||
if (module && _PyModule_GetDef(module) == def) {
|
||||
if (module && _PyModule_GetToken(module) == token) {
|
||||
res = module;
|
||||
break;
|
||||
}
|
||||
|
|
@ -5826,6 +5826,18 @@ PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
|
||||
{
|
||||
return borrow_module_by_token(type, def);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyType_GetModuleByToken(PyTypeObject *type, const void *token)
|
||||
{
|
||||
return Py_XNewRef(borrow_module_by_token(type, token));
|
||||
}
|
||||
|
||||
|
||||
static PyTypeObject *
|
||||
get_base_by_token_recursive(PyObject *bases, void *token)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue