Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a6875e

Browse files
committed
parser__pickler(): Don't drop the third argument to
parser_ast2tuple(). Create an temporary empty dictionary to use. Bug reported by Mark Favas <[email protected]>. Fix a couple of comments.
1 parent 675e994 commit 2a6875e

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

Modules/parsermodule.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ parser_free(ast)
338338
} /* parser_free() */
339339

340340

341-
/* parser_ast2tuple(PyObject* self, PyObject* args)
341+
/* parser_ast2tuple(PyObject* self, PyObject* args, PyObject* kw)
342342
*
343343
* This provides conversion from a node* to a tuple object that can be
344344
* returned to the Python-level caller. The AST object is not modified.
@@ -380,9 +380,9 @@ parser_ast2tuple(self, args, kw)
380380
} /* parser_ast2tuple() */
381381

382382

383-
/* parser_ast2tuple(PyObject* self, PyObject* args)
383+
/* parser_ast2list(PyObject* self, PyObject* args, PyObject* kw)
384384
*
385-
* This provides conversion from a node* to a tuple object that can be
385+
* This provides conversion from a node* to a list object that can be
386386
* returned to the Python-level caller. The AST object is not modified.
387387
*
388388
*/
@@ -2717,21 +2717,27 @@ parser__pickler(self, args)
27172717
NOTE(ARGUNUSED(self))
27182718
PyObject *result = NULL;
27192719
PyObject *ast = NULL;
2720+
PyObject *empty_dict = NULL;
27202721

27212722
if (PyArg_ParseTuple(args, "O!:_pickler", &PyAST_Type, &ast)) {
27222723
PyObject *newargs;
27232724
PyObject *tuple;
27242725

2725-
if ((newargs = Py_BuildValue("Oi", ast, 1)) == NULL)
2726+
if ((empty_dict = PyDict_New()) == NULL)
2727+
goto finally;
2728+
if ((newargs = Py_BuildValue("Oi", ast, 1)) == NULL)
27262729
goto finally;
2727-
tuple = parser_ast2tuple((PyAST_Object*)NULL, newargs);
2730+
tuple = parser_ast2tuple((PyAST_Object*)NULL, newargs, empty_dict);
27282731
if (tuple != NULL) {
27292732
result = Py_BuildValue("O(O)", pickle_constructor, tuple);
27302733
Py_DECREF(tuple);
27312734
}
2735+
Py_DECREF(empty_dict);
27322736
Py_DECREF(newargs);
27332737
}
27342738
finally:
2739+
Py_XDECREF(empty_dict);
2740+
27352741
return (result);
27362742

27372743
} /* parser__pickler() */

0 commit comments

Comments
 (0)