bpo-35081: Cleanup pystate.c and pystate.h (GH-10240) · python/cpython@9204fb8 · GitHub
Skip to content

Commit 9204fb8

Browse files
authored
bpo-35081: Cleanup pystate.c and pystate.h (GH-10240)
* Remove _PyThreadState_Current * Replace GET_TSTATE() with PyThreadState_GET() * Replace GET_INTERP_STATE() with _PyInterpreterState_GET_UNSAFE() * Replace direct access to _PyThreadState_Current with PyThreadState_GET() * Replace _PyThreadState_Current with _PyRuntime.gilstate.tstate_current * Rename SET_TSTATE() to _PyThreadState_SET(), name more consistent with _PyThreadState_GET() * Update outdated comments
1 parent 3c09dca commit 9204fb8

4 files changed

Lines changed: 26 additions & 31 deletions

File tree

Include/pystate.h

Lines changed: 3 additions & 4 deletions

Objects/dictobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,8 +1314,8 @@ PyDict_GetItem(PyObject *op, PyObject *key)
13141314
/* We can arrive here with a NULL tstate during initialization: try
13151315
running "python -Wi" for an example related to string interning.
13161316
Let's just hope that no exception occurs then... This must be
1317-
_PyThreadState_Current and not PyThreadState_GET() because in debug
1318-
mode, the latter complains if tstate is NULL. */
1317+
PyThreadState_GET() and not PyThreadState_Get() because the latter
1318+
abort Python if tstate is NULL. */
13191319
tstate = PyThreadState_GET();
13201320
if (tstate != NULL && tstate->curexc_type != NULL) {
13211321
/* preserve the existing exception */

Python/ceval.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ PyEval_ReleaseLock(void)
188188
We therefore avoid PyThreadState_GET() which dumps a fatal error
189189
in debug mode.
190190
*/
191-
drop_gil((PyThreadState*)_Py_atomic_load_relaxed(
192-
&_PyThreadState_Current));
191+
drop_gil(PyThreadState_GET());
193192
}
194193

195194
void

Python/pystate.c

Lines changed: 20 additions & 23 deletions

0 commit comments

Comments
 (0)