Visitar URL original
gh-101758: Add _PyState_AddModule() Back for the Stable ABI by ericsnowcurrently · Pull Request #101956 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add _PyState_AddModule() back for the stable ABI.
  • Loading branch information
ericsnowcurrently committed Feb 16, 2023
commit 32227972a9751ca5349f8d503ad8a09fb69d6c63
1 change: 1 addition & 0 deletions Lib/test/test_stable_abi_ctypes.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Misc/stable_abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,9 @@
[function._PyObject_NewVar]
added = '3.2'
abi_only = true
[function._PyState_AddModule]
added = '3.2'
abi_only = true
[function._PyThreadState_Init]
added = '3.2'
abi_only = true
Expand Down
1 change: 1 addition & 0 deletions PC/python3dll.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,26 @@ PyState_FindModule(PyModuleDef* module)
return _modules_by_index_get(interp, module);
}

/* _PyState_AddModule() has been completely removed from the C-API
(and was removed from the limited API in 3.6). However, we're
playing it safe and keeping it around for any stable ABI extensions
built against 3.2-3.5. */
int
_PyState_AddModule(PyThreadState *tstate, PyObject* module, PyModuleDef* def)
{
if (!def) {
assert(_PyErr_Occurred(tstate));
return -1;
}
if (def->m_slots) {
_PyErr_SetString(tstate,
PyExc_SystemError,
"PyState_AddModule called on module with slots");
return -1;
}
return _modules_by_index_set(tstate->interp, def, module);
}

int
PyState_AddModule(PyObject* module, PyModuleDef* def)
{
Expand Down