8000 bpo-42972: Fully support GC for _winapi.Overlapped by Fidget-Spinner · Pull Request #26381 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42972: Fully support GC for _winapi.Overlapped #26381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Apply victor's suggestions
  • Loading branch information
Fidget-Spinner committed May 27, 2021
commit 78113ccdb6e96dac11757823a30bf7bf72076acb
21 changes: 11 additions & 10 deletions Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ typedef struct {
Py_buffer write_buffer;
} OverlappedObject;

/*
Note: tp_clear (overlapped_clear) is not implemented because it
requires cancelling the IO operation if it's pending and the cancellation is
quite complex and can fail (see: overlapped_dealloc).
*/
static int
overlapped_traverse(OverlappedObject *self, visitproc visit, void *arg)
{
Expand Down Expand Up @@ -2058,29 +2063,25 @@ static PyModuleDef_Slot winapi_slots[] = {
};

static int
winapi_traverse(PyObject *m, visitproc visit, void *arg)
winapi_traverse(PyObject *module, visitproc visit, void *arg)
{
WinApiState *st = winapi_get_state(m);

WinApiState *st = winapi_get_state(module);
Py_VISIT(st->overlapped_type);

return 0;
}

static int
winapi_clear(PyObject *m)
winapi_clear(PyObject *module)
{
WinApiState *st = winapi_get_state(m);

WinApiState *st = winapi_get_state(module);
Py_CLEAR(st->overlapped_type);

return 0;
}

static void
winapi_free(void *m)
winapi_free(void *module)
{
winapi_clear((PyObject *)m);
winapi_clear((PyObject *)module);
}

static struct PyModuleDef winapi_module = {
Expand Down
0