Skip to content

Commit

Permalink
bpo-33677: Fix signatures of tp_clear handlers for AST and deque. (GH…
Browse files Browse the repository at this point in the history
…-7196) (GH-7269)

(cherry picked from commit a5c4228)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
miss-islington and serhiy-storchaka committed May 31, 2018
1 parent c2870b6 commit 0fe3be0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Modules/_collectionsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ deque_concat(dequeobject *deque, PyObject *other)
return new_deque;
}

static void
static int
deque_clear(dequeobject *deque)
{
block *b;
Expand All @@ -586,7 +586,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 @@ -647,14 +647,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 @@ -643,10 +643,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 @@ -525,10 +525,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

0 comments on commit 0fe3be0

Please sign in to comment.