Skip to content

bpo-33677: Fix signatures of tp_clear handlers for AST and deque. #7196

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 1 commit into from
May 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions Modules/_collectionsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ deque_concat(dequeobject *deque, PyObject *other)
return new_deque;
}

static void
static int
deque_clear(dequeobject *deque)
{
block *b;
Expand All @@ -587,7 +587,7 @@ deque_clear(dequeobject *deque)
PyObject **itemptr, **limit;

if (Py_SIZE(deque) == 0)
return;
return 0;

/* During the process of clearing a deque, decrefs can cause the
deque to mutate. To avoid fatal confusion, we have to make the
Expand Down Expand Up @@ -648,14 +648,15 @@ deque_clear(dequeobject *deque)
}
CHECK_END(leftblock->rightlink);
freeblock(leftblock);
return;
return 0;

alternate_method:
while (Py_SIZE(deque)) {
item = deque_pop(deque, NULL);
assert (item != NULL);
Py_DECREF(item);
}
return 0;
}

static PyObject *
Expand Down
3 changes: 2 additions & 1 deletion Parser/asdl_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,11 @@ def visitModule(self, mod):
return 0;
}

static void
static int
ast_clear(AST_object *self)
{
Py_CLEAR(self->dict);
return 0;
}

static int
Expand Down
3 changes: 2 additions & 1 deletion Python/Python-ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,11 @@ ast_traverse(AST_object *self, visitproc visit, void *arg)
return 0;
}

static void
static int
ast_clear(AST_object *self)
{
Py_CLEAR(self->dict);
return 0;
}

static int
Expand Down