Skip to content

Commit ba4c538

Browse files
committed
Remove PyThreadView.
1 parent 66e7978 commit ba4c538

4 files changed

Lines changed: 13 additions & 15 deletions

File tree

Include/cpython/pystate.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,9 @@ PyAPI_FUNC(PyInterpreterView) PyUnstable_InterpreterView_FromDefault(void);
369369
} while (0)
370370
#endif
371371

372-
typedef uintptr_t PyThreadView;
372+
PyAPI_FUNC(PyThreadState *) PyThreadState_Ensure(PyInterpreterGuard guard);
373373

374-
PyAPI_FUNC(PyThreadView) PyThreadState_Ensure(PyInterpreterGuard guard);
375-
376-
PyAPI_FUNC(void) PyThreadState_Release(PyThreadView thread_ref);
374+
PyAPI_FUNC(void) PyThreadState_Release(PyThreadState *tstate);
377375

378376
PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameAllowSpecialization(
379377
PyInterpreterState *interp,

Modules/_testcapimodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,7 @@ test_thread_state_ensure_nested(PyObject *self, PyObject *unused)
26632663
}
26642664
PyThreadState *save_tstate = PyThreadState_Swap(NULL);
26652665
assert(PyGILState_GetThisThreadState() == save_tstate);
2666-
PyThreadView thread_views[10];
2666+
PyThreadState * thread_views[10];
26672667

26682668
for (int i = 0; i < 10; ++i) {
26692669
// Test reactivation of the detached tstate.
@@ -2730,7 +2730,7 @@ test_thread_state_ensure_crossinterp(PyObject *self, PyObject *unused)
27302730
interp = interpreters.create()
27312731
interp.exec(some_func)
27322732
*/
2733-
PyThreadView thread_view = PyThreadState_Ensure(guard);
2733+
PyThreadState * thread_view = PyThreadState_Ensure(guard);
27342734
if (thread_view == 0) {
27352735
PyInterpreterGuard_Release(guard);
27362736
return PyErr_NoMemory();
@@ -2742,7 +2742,7 @@ test_thread_state_ensure_crossinterp(PyObject *self, PyObject *unused)
27422742
assert(PyGILState_GetThisThreadState() == ensured_tstate);
27432743

27442744
// Now though, we should reactivate the thread state
2745-
PyThreadView other_thread_view = PyThreadState_Ensure(guard);
2745+
PyThreadState * other_thread_view = PyThreadState_Ensure(guard);
27462746
if (other_thread_view == 0) {
27472747
PyThreadState_Release(thread_view);
27482748
PyInterpreterGuard_Release(guard);

Programs/_testembed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2690,7 +2690,7 @@ static void
26902690
do_tstate_ensure(void *arg)
26912691
{
26922692
ThreadData *data = (ThreadData *)arg;
2693-
PyThreadView refs[4];
2693+
PyThreadState * refs[4];
26942694
refs[0] = PyThreadState_Ensure(data->guard);
26952695
refs[1] = PyThreadState_Ensure(data->guard);
26962696
refs[2] = PyThreadState_Ensure(data->guard);

Python/pystate.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,15 +3492,15 @@ PyUnstable_InterpreterView_FromDefault(void)
34923492
// thread state was attached.
34933493
static int NO_TSTATE_SENTINEL = 0;
34943494

3495-
PyThreadView
3495+
PyThreadState *
34963496
PyThreadState_Ensure(PyInterpreterGuard guard)
34973497
{
34983498
PyInterpreterState *interp = guard_as_interp(guard);
34993499
PyThreadState *attached_tstate = current_fast_get();
35003500
if (attached_tstate != NULL && attached_tstate->interp == interp) {
35013501
/* Yay! We already have an attached thread state that matches. */
35023502
++attached_tstate->ensure.counter;
3503-
return (PyThreadView)&NO_TSTATE_SENTINEL;
3503+
return (PyThreadState *)&NO_TSTATE_SENTINEL;
35043504
}
35053505

35063506
PyThreadState *detached_gilstate = gilstate_get();
@@ -3509,7 +3509,7 @@ PyThreadState_Ensure(PyInterpreterGuard guard)
35093509
assert(attached_tstate == NULL);
35103510
++detached_gilstate->ensure.counter;
35113511
_PyThreadState_Attach(detached_gilstate);
3512-
return (PyThreadView)&NO_TSTATE_SENTINEL;
3512+
return (PyThreadState *)&NO_TSTATE_SENTINEL;
35133513
}
35143514

35153515
PyThreadState *fresh_tstate = _PyThreadState_NewBound(interp,
@@ -3521,16 +3521,16 @@ PyThreadState_Ensure(PyInterpreterGuard guard)
35213521
fresh_tstate->ensure.delete_on_release = 1;
35223522

35233523
if (attached_tstate != NULL) {
3524-
return (PyThreadView)PyThreadState_Swap(fresh_tstate);
3524+
return (PyThreadState *)PyThreadState_Swap(fresh_tstate);
35253525
} else {
35263526
_PyThreadState_Attach(fresh_tstate);
35273527
}
35283528

3529-
return (PyThreadView)&NO_TSTATE_SENTINEL;
3529+
return (PyThreadState *)&NO_TSTATE_SENTINEL;
35303530
}
35313531

35323532
void
3533-
PyThreadState_Release(PyThreadView thread_view)
3533+
PyThreadState_Release(PyThreadState * thread_view)
35343534
{
35353535
PyThreadState *tstate = current_fast_get();
35363536
_Py_EnsureTstateNotNULL(tstate);
@@ -3540,7 +3540,7 @@ PyThreadState_Release(PyThreadView thread_view)
35403540
}
35413541
// The thread view might be NULL
35423542
PyThreadState *to_restore;
3543-
if (thread_view == (PyThreadView)&NO_TSTATE_SENTINEL) {
3543+
if (thread_view == (PyThreadState *)&NO_TSTATE_SENTINEL) {
35443544
to_restore = NULL;
35453545
}
35463546
else {

0 commit comments

Comments
 (0)