Skip to content

Commit a5c4228

Browse files
bpo-33677: Fix signatures of tp_clear handlers for AST and deque. (GH-7196)
1 parent 5d6c7ed commit a5c4228

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
@@ -575,7 +575,7 @@ deque_concat(dequeobject *deque, PyObject *other)
575575
return new_deque;
576576
}
577577

578-
static void
578+
static int
579579
deque_clear(dequeobject *deque)
580580
{
581581
block *b;
@@ -587,7 +587,7 @@ deque_clear(dequeobject *deque)
587587
PyObject **itemptr, **limit;
588588

589589
if (Py_SIZE(deque) == 0)
590-
return;
590+
return 0;
591591

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

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

661662
static PyObject *

Parser/asdl_c.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,11 @@ def visitModule(self, mod):
647647
return 0;
648648
}
649649
650-
static void
650+
static int
651651
ast_clear(AST_object *self)
652652
{
653653
Py_CLEAR(self->dict);
654+
return 0;
654655
}
655656
656657
static int

Python/Python-ast.c

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

531-
static void
531+
static int
532532
ast_clear(AST_object *self)
533533
{
534534
Py_CLEAR(self->dict);
535+
return 0;
535536
}
536537

537538
static int

0 commit comments

Comments
 (0)