Skip to content

Commit 6c7d5c6

Browse files
authored
gh-111178: Fix function signatures in Python-ast.c (#124942)
1 parent f66d785 commit 6c7d5c6

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

Parser/asdl_c.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,9 @@ def visitModule(self, mod):
843843
} AST_object;
844844
845845
static void
846-
ast_dealloc(AST_object *self)
846+
ast_dealloc(PyObject *op)
847847
{
848+
AST_object *self = (AST_object*)op;
848849
/* bpo-31095: UnTrack is needed before calling any callbacks */
849850
PyTypeObject *tp = Py_TYPE(self);
850851
PyObject_GC_UnTrack(self);
@@ -856,16 +857,18 @@ def visitModule(self, mod):
856857
}
857858
858859
static int
859-
ast_traverse(AST_object *self, visitproc visit, void *arg)
860+
ast_traverse(PyObject *op, visitproc visit, void *arg)
860861
{
862+
AST_object *self = (AST_object*)op;
861863
Py_VISIT(Py_TYPE(self));
862864
Py_VISIT(self->dict);
863865
return 0;
864866
}
865867
866868
static int
867-
ast_clear(AST_object *self)
869+
ast_clear(PyObject *op)
868870
{
871+
AST_object *self = (AST_object*)op;
869872
Py_CLEAR(self->dict);
870873
return 0;
871874
}
@@ -1651,9 +1654,9 @@ def visitModule(self, mod):
16511654
}
16521655
16531656
static PyObject *
1654-
ast_repr(AST_object *self)
1657+
ast_repr(PyObject *self)
16551658
{
1656-
return ast_repr_max_depth(self, 3);
1659+
return ast_repr_max_depth((AST_object*)self, 3);
16571660
}
16581661
16591662
static PyType_Slot AST_type_slots[] = {
@@ -1847,8 +1850,9 @@ def visitModule(self, mod):
18471850

18481851
self.file.write(textwrap.dedent('''
18491852
static int
1850-
init_types(struct ast_state *state)
1853+
init_types(void *arg)
18511854
{
1855+
struct ast_state *state = arg;
18521856
if (init_identifiers(state) < 0) {
18531857
return -1;
18541858
}
@@ -2296,7 +2300,7 @@ def generate_module_def(mod, metadata, f, internal_h):
22962300
};
22972301
22982302
// Forward declaration
2299-
static int init_types(struct ast_state *state);
2303+
static int init_types(void *arg);
23002304
23012305
static struct ast_state*
23022306
get_ast_state(void)

Python/Python-ast.c

Lines changed: 11 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)