Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4d8959b

Browse filesBrowse files
gh-101758: Add _PyState_AddModule() Back for the Stable ABI (gh-101956)
We're adding the function back, only for the stable ABI symbol and not as any form of API. I had removed it yesterday. This undocumented "private" function was added with the implementation for PEP 3121 (3.0, 2007) for internal use and later moved out of the limited API (3.6, 2016) and then into the internal API (3.9, 2019). I removed it completely yesterday, including from the stable ABI manifest (where it was added because the symbol happened to be exported). It's unlikely that anyone is using _PyState_AddModule(), especially any stable ABI extensions built against 3.2-3.5, but we're playing it safe. #101758
1 parent a5024a2 commit 4d8959b
Copy full SHA for 4d8959b

File tree

Expand file treeCollapse file tree

5 files changed

+31
-0
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+31
-0
lines changed

‎Include/internal/pycore_pystate.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_pystate.h
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ extern void _PySignal_AfterFork(void);
152152
#endif
153153

154154

155+
PyAPI_FUNC(int) _PyState_AddModule(
156+
PyThreadState *tstate,
157+
PyObject* module,
158+
PyModuleDef* def);
159+
160+
155161
PyAPI_FUNC(int) _PyOS_InterruptOccurred(PyThreadState *tstate);
156162

157163
#define HEAD_LOCK(runtime) \

‎Lib/test/test_stable_abi_ctypes.py

Copy file name to clipboardExpand all lines: Lib/test/test_stable_abi_ctypes.py
+1Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Misc/stable_abi.toml

Copy file name to clipboardExpand all lines: Misc/stable_abi.toml
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,9 @@
16841684
[function._PyObject_NewVar]
16851685
added = '3.2'
16861686
abi_only = true
1687+
[function._PyState_AddModule]
1688+
added = '3.2'
1689+
abi_only = true
16871690
[function._PyThreadState_Init]
16881691
added = '3.2'
16891692
abi_only = true

‎PC/python3dll.c

Copy file name to clipboardExpand all lines: PC/python3dll.c
+1Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Python/import.c

Copy file name to clipboardExpand all lines: Python/import.c
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,26 @@ PyState_FindModule(PyModuleDef* module)
487487
return _modules_by_index_get(interp, module);
488488
}
489489

490+
/* _PyState_AddModule() has been completely removed from the C-API
491+
(and was removed from the limited API in 3.6). However, we're
492+
playing it safe and keeping it around for any stable ABI extensions
493+
built against 3.2-3.5. */
494+
int
495+
_PyState_AddModule(PyThreadState *tstate, PyObject* module, PyModuleDef* def)
496+
{
497+
if (!def) {
498+
assert(_PyErr_Occurred(tstate));
499+
return -1;
500+
}
501+
if (def->m_slots) {
502+
_PyErr_SetString(tstate,
503+
PyExc_SystemError,
504+
"PyState_AddModule called on module with slots");
505+
return -1;
506+
}
507+
return _modules_by_index_set(tstate->interp, def, module);
508+
}
509+
490510
int
491511
PyState_AddModule(PyObject* module, PyModuleDef* def)
492512
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.