bpo-42972: Fix GC assertion error in _winapi by untracking Overlapped earlier (GH(26429)

This commit is contained in:
Ken Jin 2021-05-29 00:29:19 +08:00 committed by GitHub
parent 0fa282c55f
commit 490b638e63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,6 +132,7 @@ overlapped_dealloc(OverlappedObject *self)
DWORD bytes;
int err = GetLastError();
PyObject_GC_UnTrack(self);
if (self->pending) {
if (check_CancelIoEx() &&
Py_CancelIoEx(self->handle, &self->overlapped) &&
@ -164,7 +165,6 @@ overlapped_dealloc(OverlappedObject *self)
CloseHandle(self->overlapped.hEvent);
SetLastError(err);
PyObject_GC_UnTrack(self);
if (self->write_buffer.obj)
PyBuffer_Release(&self->write_buffer);
Py_CLEAR(self->read_buffer);