Skip to content

Commit c40f162

Browse files
Drop PyThreadState.whence.
1 parent 0ec39ff commit c40f162

File tree

7 files changed

+13
-37
lines changed

7 files changed

+13
-37
lines changed

Include/cpython/pystate.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,6 @@ struct _ts {
143143
/* padding to align to 4 bytes */
144144
unsigned int :24;
145145
} _status;
146-
#ifdef Py_BUILD_CORE
147-
# define _PyThreadState_WHENCE_NOTSET -1
148-
# define _PyThreadState_WHENCE_UNKNOWN 0
149-
# define _PyThreadState_WHENCE_INTERP 1
150-
# define _PyThreadState_WHENCE_THREADING 2
151-
# define _PyThreadState_WHENCE_GILSTATE 3
152-
# define _PyThreadState_WHENCE_EXEC 4
153-
#endif
154-
int _whence;
155146

156147
int py_recursion_remaining;
157148
int py_recursion_limit;

Include/internal/pycore_pystate.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ static inline PyInterpreterState* _PyInterpreterState_GET(void) {
133133

134134
// PyThreadState functions
135135

136-
PyAPI_FUNC(PyThreadState *) _PyThreadState_New(
137-
PyInterpreterState *interp,
138-
int whence);
136+
PyAPI_FUNC(PyThreadState *) _PyThreadState_New(PyInterpreterState *interp);
139137
PyAPI_FUNC(void) _PyThreadState_Bind(PyThreadState *tstate);
140138
// We keep this around exclusively for stable ABI compatibility.
141139
PyAPI_FUNC(void) _PyThreadState_Init(

Include/internal/pycore_runtime_init.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ extern PyTypeObject _PyExc_MemoryError;
127127

128128
#define _PyThreadState_INIT \
129129
{ \
130-
._whence = _PyThreadState_WHENCE_NOTSET, \
131130
.py_recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
132131
.context_ver = 1, \
133132
}

Modules/_threadmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
12031203
if (boot == NULL) {
12041204
return PyErr_NoMemory();
12051205
}
1206-
boot->tstate = _PyThreadState_New(interp, _PyThreadState_WHENCE_THREADING);
1206+
boot->tstate = _PyThreadState_New(interp);
12071207
if (boot->tstate == NULL) {
12081208
PyMem_RawFree(boot);
12091209
if (!PyErr_Occurred()) {

Modules/_xxsubinterpretersmodule.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ _run_script_in_interpreter(PyObject *mod, PyInterpreterState *interp,
483483
PyThreadState *tstate = NULL;
484484
if (interp != PyInterpreterState_Get()) {
485485
tstate = PyThreadState_New(interp);
486-
tstate->_whence = _PyThreadState_WHENCE_EXEC;
487486
// XXX Possible GILState issues?
488487
save_tstate = PyThreadState_Swap(tstate);
489488
}
@@ -611,7 +610,6 @@ interp_destroy(PyObject *self, PyObject *args, PyObject *kwds)
611610

612611
// Destroy the interpreter.
613612
PyThreadState *tstate = PyThreadState_New(interp);
614-
tstate->_whence = _PyThreadState_WHENCE_INTERP;
615613
// XXX Possible GILState issues?
616614
PyThreadState *save_tstate = PyThreadState_Swap(tstate);
617615
Py_EndInterpreter(tstate);

Python/pylifecycle.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,7 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
650650
return status;
651651
}
652652

653-
PyThreadState *tstate = _PyThreadState_New(interp,
654-
_PyThreadState_WHENCE_INTERP);
653+
PyThreadState *tstate = _PyThreadState_New(interp);
655654
if (tstate == NULL) {
656655
return _PyStatus_ERR("can't make first thread");
657656
}
@@ -2026,8 +2025,7 @@ new_interpreter(PyThreadState **tstate_p, const PyInterpreterConfig *config)
20262025
return _PyStatus_OK();
20272026
}
20282027

2029-
PyThreadState *tstate = _PyThreadState_New(interp,
2030-
_PyThreadState_WHENCE_INTERP);
2028+
PyThreadState *tstate = _PyThreadState_New(interp);
20312029
if (tstate == NULL) {
20322030
PyInterpreterState_Delete(interp);
20332031
*tstate_p = NULL;

Python/pystate.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,6 @@ _PyInterpreterState_SetNotRunningMain(PyInterpreterState *interp)
10731073
// thread, so it was set as threading._main_thread. (See gh-75698.)
10741074
// The thread has finished running the Python program so we mark
10751075
// the thread object as finished.
1076-
assert(tstate->_whence != _PyThreadState_WHENCE_THREADING);
10771076
tstate->on_delete(tstate->on_delete_data);
10781077
tstate->on_delete = NULL;
10791078
tstate->on_delete_data = NULL;
@@ -1159,8 +1158,7 @@ _PyInterpreterState_IDDecref(PyInterpreterState *interp)
11591158
PyThread_release_lock(interp->id_mutex);
11601159

11611160
if (refcount == 0 && interp->requires_idref) {
1162-
PyThreadState *tstate = _PyThreadState_New(interp,
1163-
_PyThreadState_WHENCE_INTERP);
1161+
PyThreadState *tstate = _PyThreadState_New(interp);
11641162
_PyThreadState_Bind(tstate);
11651163

11661164
// XXX Possible GILState issues?
@@ -1338,7 +1336,7 @@ free_threadstate(PyThreadState *tstate)
13381336

13391337
static void
13401338
init_threadstate(PyThreadState *tstate,
1341-
PyInterpreterState *interp, uint64_t id, int whence)
1339+
PyInterpreterState *interp, uint64_t id)
13421340
{
13431341
if (tstate->_status.initialized) {
13441342
Py_FatalError("thread state already initialized");
@@ -1351,10 +1349,6 @@ init_threadstate(PyThreadState *tstate,
13511349
assert(tstate->next == NULL);
13521350
assert(tstate->prev == NULL);
13531351

1354-
assert(tstate->_whence == _PyThreadState_WHENCE_NOTSET);
1355-
assert(whence >= 0 && whence <= _PyThreadState_WHENCE_EXEC);
1356-
tstate->_whence = whence;
1357-
13581352
assert(id > 0);
13591353
tstate->id = id;
13601354

@@ -1394,7 +1388,7 @@ add_threadstate(PyInterpreterState *interp, PyThreadState *tstate,
13941388
}
13951389

13961390
static PyThreadState *
1397-
new_threadstate(PyInterpreterState *interp, int whence)
1391+
new_threadstate(PyInterpreterState *interp)
13981392
{
13991393
PyThreadState *tstate;
14001394
_PyRuntimeState *runtime = interp->runtime;
@@ -1433,7 +1427,7 @@ new_threadstate(PyInterpreterState *interp, int whence)
14331427
sizeof(*tstate));
14341428
}
14351429

1436-
init_threadstate(tstate, interp, id, whence);
1430+
init_threadstate(tstate, interp, id);
14371431
add_threadstate(interp, tstate, old_head);
14381432

14391433
HEAD_UNLOCK(runtime);
@@ -1447,8 +1441,7 @@ new_threadstate(PyInterpreterState *interp, int whence)
14471441
PyThreadState *
14481442
PyThreadState_New(PyInterpreterState *interp)
14491443
{
1450-
PyThreadState *tstate = new_threadstate(interp,
1451-
_PyThreadState_WHENCE_UNKNOWN);
1444+
PyThreadState *tstate = new_threadstate(interp);
14521445
if (tstate) {
14531446
bind_tstate(tstate);
14541447
// This makes sure there's a gilstate tstate bound
@@ -1462,16 +1455,16 @@ PyThreadState_New(PyInterpreterState *interp)
14621455

14631456
// This must be followed by a call to _PyThreadState_Bind();
14641457
PyThreadState *
1465-
_PyThreadState_New(PyInterpreterState *interp, int whence)
1458+
_PyThreadState_New(PyInterpreterState *interp)
14661459
{
1467-
return new_threadstate(interp, whence);
1460+
return new_threadstate(interp);
14681461
}
14691462

14701463
// We keep this for stable ABI compabibility.
14711464
PyThreadState *
14721465
_PyThreadState_Prealloc(PyInterpreterState *interp)
14731466
{
1474-
return _PyThreadState_New(interp, _PyThreadState_WHENCE_UNKNOWN);
1467+
return _PyThreadState_New(interp);
14751468
}
14761469

14771470
// We keep this around for (accidental) stable ABI compatibility.
@@ -2235,8 +2228,7 @@ PyGILState_Ensure(void)
22352228
if (tcur == NULL) {
22362229
/* Create a new Python thread state for this thread */
22372230
// XXX Use PyInterpreterState_EnsureThreadState()?
2238-
tcur = new_threadstate(runtime->gilstate.autoInterpreterState,
2239-
_PyThreadState_WHENCE_GILSTATE);
2231+
tcur = new_threadstate(runtime->gilstate.autoInterpreterState);
22402232
if (tcur == NULL) {
22412233
Py_FatalError("Couldn't create thread-state for new thread");
22422234
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy