]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42972: Fix GC assertion error in _winapi by untracking Overlapped earlier (GH...
authorKen Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Fri, 28 May 2021 16:29:19 +0000 (00:29 +0800)
committerGitHub <noreply@github.com>
Fri, 28 May 2021 16:29:19 +0000 (18:29 +0200)
Modules/_winapi.c

index 30fcb4e1768eef4ac3006aa41506bcd5b71109b7..2c034628e34e9461e9c7df0fe4a8782be0a24165 100644 (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);