mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
parser__pickler(): Don't drop the third argument to
parser_ast2tuple(). Create an temporary empty dictionary to use. Bug reported by Mark Favas <m.favas@per.dem.csiro.au>. Fix a couple of comments.
This commit is contained in:
parent
675e994a2e
commit
2a6875e172
1 changed files with 11 additions and 5 deletions
|
@ -338,7 +338,7 @@ parser_free(ast)
|
||||||
} /* parser_free() */
|
} /* parser_free() */
|
||||||
|
|
||||||
|
|
||||||
/* parser_ast2tuple(PyObject* self, PyObject* args)
|
/* parser_ast2tuple(PyObject* self, PyObject* args, PyObject* kw)
|
||||||
*
|
*
|
||||||
* This provides conversion from a node* to a tuple object that can be
|
* This provides conversion from a node* to a tuple object that can be
|
||||||
* returned to the Python-level caller. The AST object is not modified.
|
* returned to the Python-level caller. The AST object is not modified.
|
||||||
|
@ -380,9 +380,9 @@ parser_ast2tuple(self, args, kw)
|
||||||
} /* parser_ast2tuple() */
|
} /* parser_ast2tuple() */
|
||||||
|
|
||||||
|
|
||||||
/* parser_ast2tuple(PyObject* self, PyObject* args)
|
/* parser_ast2list(PyObject* self, PyObject* args, PyObject* kw)
|
||||||
*
|
*
|
||||||
* This provides conversion from a node* to a tuple object that can be
|
* This provides conversion from a node* to a list object that can be
|
||||||
* returned to the Python-level caller. The AST object is not modified.
|
* returned to the Python-level caller. The AST object is not modified.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -2717,21 +2717,27 @@ parser__pickler(self, args)
|
||||||
NOTE(ARGUNUSED(self))
|
NOTE(ARGUNUSED(self))
|
||||||
PyObject *result = NULL;
|
PyObject *result = NULL;
|
||||||
PyObject *ast = NULL;
|
PyObject *ast = NULL;
|
||||||
|
PyObject *empty_dict = NULL;
|
||||||
|
|
||||||
if (PyArg_ParseTuple(args, "O!:_pickler", &PyAST_Type, &ast)) {
|
if (PyArg_ParseTuple(args, "O!:_pickler", &PyAST_Type, &ast)) {
|
||||||
PyObject *newargs;
|
PyObject *newargs;
|
||||||
PyObject *tuple;
|
PyObject *tuple;
|
||||||
|
|
||||||
if ((newargs = Py_BuildValue("Oi", ast, 1)) == NULL)
|
if ((empty_dict = PyDict_New()) == NULL)
|
||||||
|
goto finally;
|
||||||
|
if ((newargs = Py_BuildValue("Oi", ast, 1)) == NULL)
|
||||||
goto finally;
|
goto finally;
|
||||||
tuple = parser_ast2tuple((PyAST_Object*)NULL, newargs);
|
tuple = parser_ast2tuple((PyAST_Object*)NULL, newargs, empty_dict);
|
||||||
if (tuple != NULL) {
|
if (tuple != NULL) {
|
||||||
result = Py_BuildValue("O(O)", pickle_constructor, tuple);
|
result = Py_BuildValue("O(O)", pickle_constructor, tuple);
|
||||||
Py_DECREF(tuple);
|
Py_DECREF(tuple);
|
||||||
}
|
}
|
||||||
|
Py_DECREF(empty_dict);
|
||||||
Py_DECREF(newargs);
|
Py_DECREF(newargs);
|
||||||
}
|
}
|
||||||
finally:
|
finally:
|
||||||
|
Py_XDECREF(empty_dict);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
|
|
||||||
} /* parser__pickler() */
|
} /* parser__pickler() */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue