From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Fri, 28 May 2021 16:29:19 +0000 (+0800) Subject: bpo-42972: Fix GC assertion error in _winapi by untracking Overlapped earlier (GH... X-Git-Tag: v3.11.0a1~999 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=490b638e63558013b71dbfba6e47cb9e6d80c911;p=thirdparty%2FPython%2Fcpython.git bpo-42972: Fix GC assertion error in _winapi by untracking Overlapped earlier (GH(26429) --- diff --git a/Modules/_winapi.c b/Modules/_winapi.c index 30fcb4e1768e..2c034628e34e 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -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);