Skip to content

Commit 46c2709

Browse files
committed
Use variable
1 parent b947bc9 commit 46c2709

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Python/ceval.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,16 +2378,18 @@ PyEval_SetProfileAllThreads(Py_tracefunc func, PyObject *arg)
23782378
PyThreadState *this_tstate = _PyThreadState_GET();
23792379
PyInterpreterState *interp = this_tstate->interp;
23802380

2381-
HEAD_LOCK(&_PyRuntime);
2381+
_PyRuntimeState *runtime = &_PyRuntime;
2382+
HEAD_LOCK(runtime);
23822383
PyThreadState *ts = PyInterpreterState_ThreadHead(interp);
2383-
HEAD_UNLOCK(&_PyRuntime);
2384+
HEAD_UNLOCK(runtime);
2385+
23842386
while (ts) {
23852387
if (_PyEval_SetProfile(ts, func, arg) < 0) {
23862388
PyErr_FormatUnraisable("Exception ignored in PyEval_SetProfileAllThreads");
23872389
}
2388-
HEAD_LOCK(&_PyRuntime);
2390+
HEAD_LOCK(runtime);
23892391
ts = PyThreadState_Next(ts);
2390-
HEAD_UNLOCK(&_PyRuntime);
2392+
HEAD_UNLOCK(runtime);
23912393
}
23922394
}
23932395

@@ -2407,16 +2409,18 @@ PyEval_SetTraceAllThreads(Py_tracefunc func, PyObject *arg)
24072409
PyThreadState *this_tstate = _PyThreadState_GET();
24082410
PyInterpreterState *interp = this_tstate->interp;
24092411

2410-
HEAD_LOCK(&_PyRuntime);
2412+
_PyRuntimeState *runtime = &_PyRuntime;
2413+
HEAD_LOCK(runtime);
24112414
PyThreadState *ts = PyInterpreterState_ThreadHead(interp);
2412-
HEAD_UNLOCK(&_PyRuntime);
2415+
HEAD_UNLOCK(runtime);
2416+
24132417
while (ts) {
24142418
if (_PyEval_SetTrace(ts, func, arg) < 0) {
24152419
PyErr_FormatUnraisable("Exception ignored in PyEval_SetTraceAllThreads");
24162420
}
2417-
HEAD_LOCK(&_PyRuntime);
2421+
HEAD_LOCK(runtime);
24182422
ts = PyThreadState_Next(ts);
2419-
HEAD_UNLOCK(&_PyRuntime);
2423+
HEAD_UNLOCK(runtime);
24202424
}
24212425
}
24222426

0 commit comments

Comments
 (0)