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

vstinner webhook-mailer at python.org
Fri May 28 12:29:27 EDT 2021


https://github.com/python/cpython/commit/490b638e63558013b71dbfba6e47cb9e6d80c911
commit: 490b638e63558013b71dbfba6e47cb9e6d80c911
branch: main
author: Ken Jin <28750310+Fidget-Spinner at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2021-05-28T18:29:19+02:00
summary:

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

files:
M Modules/_winapi.c

diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index 30fcb4e1768eef..2c034628e34e94 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);



More information about the Python-checkins mailing list