summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c18
-rw-r--r--Python/ast.c10
2 files changed, 17 insertions, 11 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 2603b812f0..1178d74d7f 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -1,5 +1,7 @@
/* File automatically generated by Parser/asdl_c.py. */
+#include <stddef.h>
+
#include "Python.h"
#include "Python-ast.h"
@@ -453,6 +455,11 @@ static char *withitem_fields[]={
};
+typedef struct {
+ PyObject_HEAD
+ PyObject *dict;
+} AST_object;
+
static int
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
{
@@ -531,10 +538,15 @@ static PyMethodDef ast_type_methods[] = {
{NULL}
};
+static PyGetSetDef ast_type_getsets[] = {
+ {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
+ {NULL}
+};
+
static PyTypeObject AST_type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"_ast.AST",
- sizeof(PyObject),
+ sizeof(AST_object),
0,
0, /* tp_dealloc */
0, /* tp_print */
@@ -561,12 +573,12 @@ static PyTypeObject AST_type = {
0, /* tp_iternext */
ast_type_methods, /* tp_methods */
0, /* tp_members */
- 0, /* tp_getset */
+ ast_type_getsets, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
- 0, /* tp_dictoffset */
+ offsetof(AST_object, dict),/* tp_dictoffset */
(initproc)ast_type_init, /* tp_init */
PyType_GenericAlloc, /* tp_alloc */
PyType_GenericNew, /* tp_new */
diff --git a/Python/ast.c b/Python/ast.c
index 0f93098712..eb8aed2a2e 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -1153,7 +1153,7 @@ seq_for_testlist(struct compiling *c, const node *n)
}
static arg_ty
-compiler_arg(struct compiling *c, const node *n)
+ast_for_arg(struct compiling *c, const node *n)
{
identifier name;
expr_ty annotation = NULL;
@@ -1174,12 +1174,6 @@ compiler_arg(struct compiling *c, const node *n)
}
return arg(name, annotation, c->c_arena);
-#if 0
- result = Tuple(args, Store, LINENO(n), n->n_col_offset, c->c_arena);
- if (!set_context(c, result, Store, n))
- return NULL;
- return result;
-#endif
}
/* returns -1 if failed to handle keyword only arguments
@@ -1367,7 +1361,7 @@ ast_for_arguments(struct compiling *c, const node *n)
"non-default argument follows default argument");
return NULL;
}
- arg = compiler_arg(c, ch);
+ arg = ast_for_arg(c, ch);
if (!arg)
return NULL;
asdl_seq_SET(posargs, k++, arg);