Skip to content

Commit c5148d1

Browse files
committed
Avoid using a second sentinel.
1 parent 0945129 commit c5148d1

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

Python/pystate.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,9 +3473,6 @@ PyInterpreterView_FromMain(void)
34733473
static const PyThreadStateToken *_no_tstate_sentinel = (const PyThreadStateToken *)&_no_tstate_sentinel;
34743474
#define NO_TSTATE_SENTINEL ((PyThreadStateToken *)_no_tstate_sentinel)
34753475

3476-
static const PyThreadStateToken *_detached_sentinel = (const PyThreadStateToken *)&_detached_sentinel;
3477-
#define DETACHED_TSTATE_SENTINEL ((PyThreadStateToken *)_detached_sentinel)
3478-
34793476
PyThreadStateToken *
34803477
PyThreadState_Ensure(PyInterpreterGuard *guard)
34813478
{
@@ -3495,7 +3492,7 @@ PyThreadState_Ensure(PyInterpreterGuard *guard)
34953492
assert(attached_tstate == NULL);
34963493
++detached_gilstate->ensure.counter;
34973494
_PyThreadState_Attach(detached_gilstate);
3498-
return DETACHED_TSTATE_SENTINEL;
3495+
return NO_TSTATE_SENTINEL;
34993496
}
35003497

35013498
PyThreadState *fresh_tstate = _PyThreadState_NewBound(interp,
@@ -3557,14 +3554,14 @@ PyThreadState_Release(PyThreadStateToken *token)
35573554
if (remaining != 0) {
35583555
// If the corresponding PyThreadState_Ensure() call used a detached
35593556
// thread state, we want to detach it again.
3560-
if (token == DETACHED_TSTATE_SENTINEL) {
3557+
if (token == NO_TSTATE_SENTINEL) {
35613558
PyThreadState_Swap(NULL);
35623559
}
35633560
return;
35643561
}
35653562

35663563
PyThreadState *to_restore;
3567-
if (token == NO_TSTATE_SENTINEL || token == DETACHED_TSTATE_SENTINEL) {
3564+
if (token == NO_TSTATE_SENTINEL) {
35683565
to_restore = NULL;
35693566
}
35703567
else {

Tools/c-analyzer/cpython/ignored.tsv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,4 +786,3 @@ Objects/dictobject.c - PyFrozenDict_Type -
786786
## False positives
787787
Python/specialize.c - _Py_InitCleanup -
788788
Python/pystate.c - _no_tstate_sentinel -
789-
Python/pystate.c - _detached_sentinel -

0 commit comments

Comments
 (0)