bpo-43268: Pass interp rather than tstate to internal functions (GH-24580)
Pass the current interpreter (interp) rather than the current Python
thread state (tstate) to internal functions which only use the
interpreter.
Modified functions:
* _PyXXX_Fini() and _PyXXX_ClearFreeList() functions
* _PyEval_SignalAsyncExc(), make_pending_calls()
* _PySys_GetObject(), sys_set_object(), sys_set_object_id(), sys_set_object_str()
* should_audit(), set_flags_from_config(), make_flags()
* _PyAtExit_Call()
* init_stdio_encoding()
* etc.
diff --git a/Objects/longobject.c b/Objects/longobject.c
index c0b4ce0..02b3603 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -5702,7 +5702,7 @@ PyLong_GetInfo(void)
}
int
-_PyLong_Init(PyThreadState *tstate)
+_PyLong_Init(PyInterpreterState *interp)
{
for (Py_ssize_t i=0; i < NSMALLNEGINTS + NSMALLPOSINTS; i++) {
sdigit ival = (sdigit)i - NSMALLNEGINTS;
@@ -5716,10 +5716,10 @@ _PyLong_Init(PyThreadState *tstate)
Py_SET_SIZE(v, size);
v->ob_digit[0] = (digit)abs(ival);
- tstate->interp->small_ints[i] = v;
+ interp->small_ints[i] = v;
}
- if (_Py_IsMainInterpreter(tstate->interp)) {
+ if (_Py_IsMainInterpreter(interp)) {
/* initialize int_info */
if (Int_InfoType.tp_name == NULL) {
if (PyStructSequence_InitType2(&Int_InfoType, &int_info_desc) < 0) {
@@ -5732,9 +5732,9 @@ _PyLong_Init(PyThreadState *tstate)
}
void
-_PyLong_Fini(PyThreadState *tstate)
+_PyLong_Fini(PyInterpreterState *interp)
{
for (Py_ssize_t i = 0; i < NSMALLNEGINTS + NSMALLPOSINTS; i++) {
- Py_CLEAR(tstate->interp->small_ints[i]);
+ Py_CLEAR(interp->small_ints[i]);
}
}