summaryrefslogtreecommitdiffstats
path: root/Modules/_interpretersmodule.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2025-04-25 20:43:38 (GMT)
committerGitHub <noreply@github.com>2025-04-25 20:43:38 (GMT)
commitcd9536a0872046cc7c151b61b457975e7718274a (patch)
tree97aeb24d67a984a1eedd1ef0944463a4b2a3ef05 /Modules/_interpretersmodule.c
parent4c20f46fa011df57190cc19b21bafde1f65e73a7 (diff)
downloadcpython-cd9536a0872046cc7c151b61b457975e7718274a.zip
cpython-cd9536a0872046cc7c151b61b457975e7718274a.tar.gz
cpython-cd9536a0872046cc7c151b61b457975e7718274a.tar.bz2
gh-132781: Cleanup Code Related to NotShareableError (gh-132782)
The following are added to the internal C-API: * _PyErr_FormatV() * _PyErr_SetModuleNotFoundError() * _PyXIData_GetNotShareableErrorType() * _PyXIData_FormatNotShareableError() We also drop _PyXIData_lookup_context_t and _PyXIData_GetLookupContext().
Diffstat (limited to 'Modules/_interpretersmodule.c')
-rw-r--r--Modules/_interpretersmodule.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/Modules/_interpretersmodule.c b/Modules/_interpretersmodule.c
index e59a53f..8ced687 100644
--- a/Modules/_interpretersmodule.c
+++ b/Modules/_interpretersmodule.c
@@ -1278,13 +1278,8 @@ object_is_shareable(PyObject *self, PyObject *args, PyObject *kwds)
return NULL;
}
- PyInterpreterState *interp = PyInterpreterState_Get();
- _PyXIData_lookup_context_t ctx;
- if (_PyXIData_GetLookupContext(interp, &ctx) < 0) {
- return NULL;
- }
-
- if (_PyObject_CheckXIData(&ctx, obj) == 0) {
+ PyThreadState *tstate = _PyThreadState_GET();
+ if (_PyObject_CheckXIData(tstate, obj) == 0) {
Py_RETURN_TRUE;
}
PyErr_Clear();
@@ -1577,14 +1572,9 @@ The 'interpreters' module provides a more convenient interface.");
static int
module_exec(PyObject *mod)
{
- PyInterpreterState *interp = PyInterpreterState_Get();
+ PyThreadState *tstate = _PyThreadState_GET();
module_state *state = get_module_state(mod);
- _PyXIData_lookup_context_t ctx;
- if (_PyXIData_GetLookupContext(interp, &ctx) < 0) {
- return -1;
- }
-
#define ADD_WHENCE(NAME) \
if (PyModule_AddIntConstant(mod, "WHENCE_" #NAME, \
_PyInterpreterState_WHENCE_##NAME) < 0) \
@@ -1606,7 +1596,8 @@ module_exec(PyObject *mod)
if (PyModule_AddType(mod, (PyTypeObject *)PyExc_InterpreterNotFoundError) < 0) {
goto error;
}
- if (PyModule_AddType(mod, (PyTypeObject *)ctx.PyExc_NotShareableError) < 0) {
+ PyObject *exctype = _PyXIData_GetNotShareableErrorType(tstate);
+ if (PyModule_AddType(mod, (PyTypeObject *)exctype) < 0) {
goto error;
}