Skip to content

Commit 0fe3be0

Browse files
bpo-33677: Fix signatures of tp_clear handlers for AST and deque. (GH-7196) (GH-7269)
(cherry picked from commit a5c4228) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent c2870b6 commit 0fe3be0

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Modules/_collectionsmodule.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ deque_concat(dequeobject *deque, PyObject *other)
574574
return new_deque;
575575
}
576576

577-
static void
577+
static int
578578
deque_clear(dequeobject *deque)
579579
{
580580
block *b;
@@ -586,7 +586,7 @@ deque_clear(dequeobject *deque)
586586
PyObject **itemptr, **limit;
587587

588588
if (Py_SIZE(deque) == 0)
589-
return;
589+
return 0;
590590

591591
/* During the process of clearing a deque, decrefs can cause the
592592
deque to mutate. To avoid fatal confusion, we have to make the
@@ -647,14 +647,15 @@ deque_clear(dequeobject *deque)
647647
}
648648
CHECK_END(leftblock->rightlink);
649649
freeblock(leftblock);
650-
return;
650+
return 0;
651651

652652
alternate_method:
653653
while (Py_SIZE(deque)) {
654654
item = deque_pop(deque, NULL);
655655
assert (item != NULL);
656656
Py_DECREF(item);
657657
}
658+
return 0;
658659
}
659660

660661
static PyObject *

Parser/asdl_c.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,10 +643,11 @@ def visitModule(self, mod):
643643
return 0;
644644
}
645645
646-
static void
646+
static int
647647
ast_clear(AST_object *self)
648648
{
649649
Py_CLEAR(self->dict);
650+
return 0;
650651
}
651652
652653
static int

Python/Python-ast.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,11 @@ ast_traverse(AST_object *self, visitproc visit, void *arg)
525525
return 0;
526526
}
527527

528-
static void
528+
static int
529529
ast_clear(AST_object *self)
530530
{
531531
Py_CLEAR(self->dict);
532+
return 0;
532533
}
533534

534535
static int

0 commit comments

Comments
 (0)