standard :class:`bytes` objects are always used.
(Contributed by Jon Janzen in :issue:`36409`.)
+* ``PyThreadState_DeleteCurrent()`` has been removed. It was not documented.
+ (Contributed by Joannah Nanjekye in :issue:`37878`.)
+
Porting to Python 3.9
=====================
PyAPI_FUNC(void) _PyErr_Display(PyObject *file, PyObject *exception,
PyObject *value, PyObject *tb);
+PyAPI_FUNC(void) _PyThreadState_DeleteCurrent(_PyRuntimeState *runtime);
+
#ifdef __cplusplus
}
#endif
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
-PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
/* Get the current thread state.
--- /dev/null
+Make :c:func:`PyThreadState_DeleteCurrent` Internal.
PyObject *args;
PyObject *keyw;
PyThreadState *tstate;
+ _PyRuntimeState *runtime;
};
static void
{
struct bootstate *boot = (struct bootstate *) boot_raw;
PyThreadState *tstate;
+ _PyRuntimeState *runtime;
PyObject *res;
+ runtime = boot->runtime;
tstate = boot->tstate;
tstate->thread_id = PyThread_get_thread_ident();
- _PyThreadState_Init(&_PyRuntime, tstate);
+ _PyThreadState_Init(runtime, tstate);
PyEval_AcquireThread(tstate);
tstate->interp->num_threads++;
res = PyObject_Call(boot->func, boot->args, boot->keyw);
PyMem_DEL(boot_raw);
tstate->interp->num_threads--;
PyThreadState_Clear(tstate);
- PyThreadState_DeleteCurrent();
+ _PyThreadState_DeleteCurrent(runtime);
PyThread_exit_thread();
}
static PyObject *
thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
{
+ _PyRuntimeState *runtime = &_PyRuntime;
PyObject *func, *args, *keyw = NULL;
struct bootstate *boot;
unsigned long ident;
boot->args = args;
boot->keyw = keyw;
boot->tstate = _PyThreadState_Prealloc(boot->interp);
+ boot->runtime = runtime;
if (boot->tstate == NULL) {
PyMem_DEL(boot);
return PyErr_NoMemory();
#if defined(TRACE_RAW_MALLOC)
/* This lock is needed because tracemalloc_free() is called without
the GIL held from PyMem_RawFree(). It cannot acquire the lock because it
- would introduce a deadlock in PyThreadState_DeleteCurrent(). */
+ would introduce a deadlock in _PyThreadState_DeleteCurrent(). */
static PyThread_type_lock tables_lock;
# define TABLES_LOCK() PyThread_acquire_lock(tables_lock, 1)
# define TABLES_UNLOCK() PyThread_release_lock(tables_lock)
return;
/* GIL cannot be locked in PyMem_RawFree() because it would introduce
- a deadlock in PyThreadState_DeleteCurrent(). */
+ a deadlock in _PyThreadState_DeleteCurrent(). */
alloc->free(alloc->ctx, ptr);
}
-/* Common code for PyThreadState_Delete() and PyThreadState_DeleteCurrent() */
+/* Common code for PyThreadState_Delete() and _PyThreadState_DeleteCurrent() */
static void
tstate_delete_common(_PyRuntimeState *runtime, PyThreadState *tstate)
{
}
-static void
+void
_PyThreadState_DeleteCurrent(_PyRuntimeState *runtime)
{
struct _gilstate_runtime_state *gilstate = &runtime->gilstate;
PyThreadState *tstate = _PyRuntimeGILState_GetThreadState(gilstate);
if (tstate == NULL)
Py_FatalError(
- "PyThreadState_DeleteCurrent: no current tstate");
+ "_PyThreadState_DeleteCurrent: no current tstate");
tstate_delete_common(runtime, tstate);
if (gilstate->autoInterpreterState &&
PyThread_tss_get(&gilstate->autoTSSkey) == tstate)
PyEval_ReleaseLock();
}
-void
-PyThreadState_DeleteCurrent()
-{
- _PyThreadState_DeleteCurrent(&_PyRuntime);
-}
-
/*
* Delete all thread states except the one passed as argument.