Skip to content

Commit

Permalink
gh-111178: Fix function signatures in Python-ast.c (#124942)
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner authored Oct 4, 2024
1 parent f66d785 commit 6c7d5c6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
18 changes: 11 additions & 7 deletions Parser/asdl_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,9 @@ def visitModule(self, mod):
} AST_object;
static void
ast_dealloc(AST_object *self)
ast_dealloc(PyObject *op)
{
AST_object *self = (AST_object*)op;
/* bpo-31095: UnTrack is needed before calling any callbacks */
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
Expand All @@ -856,16 +857,18 @@ def visitModule(self, mod):
}
static int
ast_traverse(AST_object *self, visitproc visit, void *arg)
ast_traverse(PyObject *op, visitproc visit, void *arg)
{
AST_object *self = (AST_object*)op;
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->dict);
return 0;
}
static int
ast_clear(AST_object *self)
ast_clear(PyObject *op)
{
AST_object *self = (AST_object*)op;
Py_CLEAR(self->dict);
return 0;
}
Expand Down Expand Up @@ -1651,9 +1654,9 @@ def visitModule(self, mod):
}
static PyObject *
ast_repr(AST_object *self)
ast_repr(PyObject *self)
{
return ast_repr_max_depth(self, 3);
return ast_repr_max_depth((AST_object*)self, 3);
}
static PyType_Slot AST_type_slots[] = {
Expand Down Expand Up @@ -1847,8 +1850,9 @@ def visitModule(self, mod):

self.file.write(textwrap.dedent('''
static int
init_types(struct ast_state *state)
init_types(void *arg)
{
struct ast_state *state = arg;
if (init_identifiers(state) < 0) {
return -1;
}
Expand Down Expand Up @@ -2296,7 +2300,7 @@ def generate_module_def(mod, metadata, f, internal_h):
};
// Forward declaration
static int init_types(struct ast_state *state);
static int init_types(void *arg);
static struct ast_state*
get_ast_state(void)
Expand Down
18 changes: 11 additions & 7 deletions Python/Python-ast.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c7d5c6

Please sign in to comment.