mirror of
https://github.com/python/cpython.git
synced 2024-12-02 22:35:26 +08:00
gh-76785: Clean Up the Channels Module (gh-110568)
This commit is contained in:
parent
73a003f646
commit
a77fa05124
@ -291,7 +291,7 @@ struct _xid {
|
||||
// with deleted interpreters. Note that IDs are never re-used, so
|
||||
// each one will always correspond to a specific interpreter
|
||||
// (whether still alive or not).
|
||||
int64_t interp;
|
||||
int64_t interpid;
|
||||
// new_object is a function that returns a new object in the current
|
||||
// interpreter given the data. The resulting object (a new
|
||||
// reference) will be equivalent to the original object. This field
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2428,7 +2428,7 @@ _xidata_init(_PyCrossInterpreterData *data)
|
||||
assert(data->data == NULL);
|
||||
assert(data->obj == NULL);
|
||||
*data = (_PyCrossInterpreterData){0};
|
||||
data->interp = -1;
|
||||
data->interpid = -1;
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -2465,7 +2465,7 @@ _PyCrossInterpreterData_Init(_PyCrossInterpreterData *data,
|
||||
// Ideally every object would know its owning interpreter.
|
||||
// Until then, we have to rely on the caller to identify it
|
||||
// (but we don't need it in all cases).
|
||||
data->interp = (interp != NULL) ? interp->id : -1;
|
||||
data->interpid = (interp != NULL) ? interp->id : -1;
|
||||
data->new_object = new_object;
|
||||
}
|
||||
|
||||
@ -2494,7 +2494,7 @@ _PyCrossInterpreterData_Clear(PyInterpreterState *interp,
|
||||
{
|
||||
assert(data != NULL);
|
||||
// This must be called in the owning interpreter.
|
||||
assert(interp == NULL || data->interp == interp->id);
|
||||
assert(interp == NULL || data->interpid == interp->id);
|
||||
_xidata_clear(data);
|
||||
}
|
||||
|
||||
@ -2505,7 +2505,7 @@ _check_xidata(PyThreadState *tstate, _PyCrossInterpreterData *data)
|
||||
|
||||
// data->obj may be NULL, so we don't check it.
|
||||
|
||||
if (data->interp < 0) {
|
||||
if (data->interpid < 0) {
|
||||
_PyErr_SetString(tstate, PyExc_SystemError, "missing interp");
|
||||
return -1;
|
||||
}
|
||||
@ -2557,7 +2557,7 @@ _PyObject_GetCrossInterpreterData(PyObject *obj, _PyCrossInterpreterData *data)
|
||||
|
||||
// Reset data before re-populating.
|
||||
*data = (_PyCrossInterpreterData){0};
|
||||
data->interp = -1;
|
||||
data->interpid = -1;
|
||||
|
||||
// Call the "getdata" func for the object.
|
||||
Py_INCREF(obj);
|
||||
@ -2573,7 +2573,7 @@ _PyObject_GetCrossInterpreterData(PyObject *obj, _PyCrossInterpreterData *data)
|
||||
}
|
||||
|
||||
// Fill in the blanks and validate the result.
|
||||
data->interp = interp->id;
|
||||
data->interpid = interp->id;
|
||||
if (_check_xidata(tstate, data) != 0) {
|
||||
(void)_PyCrossInterpreterData_Release(data);
|
||||
return -1;
|
||||
@ -2636,7 +2636,7 @@ _xidata_release(_PyCrossInterpreterData *data, int rawfree)
|
||||
}
|
||||
|
||||
// Switch to the original interpreter.
|
||||
PyInterpreterState *interp = _PyInterpreterState_LookUpID(data->interp);
|
||||
PyInterpreterState *interp = _PyInterpreterState_LookUpID(data->interpid);
|
||||
if (interp == NULL) {
|
||||
// The interpreter was already destroyed.
|
||||
// This function shouldn't have been called.
|
||||
|
Loading…
Reference in New Issue
Block a user