mirror of https://github.com/python/cpython
bpo-43268: local_clear() uses _PyInterpreterState_GET() (GH-24583)
Cleanup also the code.
This commit is contained in:
parent
bcb094b41f
commit
839184f85c
|
@ -828,27 +828,26 @@ local_traverse(localobject *self, visitproc visit, void *arg)
|
||||||
static int
|
static int
|
||||||
local_clear(localobject *self)
|
local_clear(localobject *self)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate;
|
|
||||||
Py_CLEAR(self->args);
|
Py_CLEAR(self->args);
|
||||||
Py_CLEAR(self->kw);
|
Py_CLEAR(self->kw);
|
||||||
Py_CLEAR(self->dummies);
|
Py_CLEAR(self->dummies);
|
||||||
Py_CLEAR(self->wr_callback);
|
Py_CLEAR(self->wr_callback);
|
||||||
/* Remove all strong references to dummies from the thread states */
|
/* Remove all strong references to dummies from the thread states */
|
||||||
if (self->key
|
if (self->key) {
|
||||||
&& (tstate = PyThreadState_Get())
|
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||||
&& tstate->interp) {
|
PyThreadState *tstate = PyInterpreterState_ThreadHead(interp);
|
||||||
for(tstate = PyInterpreterState_ThreadHead(tstate->interp);
|
for(; tstate; tstate = PyThreadState_Next(tstate)) {
|
||||||
tstate;
|
if (tstate->dict == NULL) {
|
||||||
tstate = PyThreadState_Next(tstate))
|
continue;
|
||||||
if (tstate->dict) {
|
|
||||||
PyObject *v = _PyDict_Pop(tstate->dict, self->key, Py_None);
|
|
||||||
if (v == NULL) {
|
|
||||||
PyErr_Clear();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Py_DECREF(v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
PyObject *v = _PyDict_Pop(tstate->dict, self->key, Py_None);
|
||||||
|
if (v != NULL) {
|
||||||
|
Py_DECREF(v);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PyErr_Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue