diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index eac770ece2e319..69da417c67cbab 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -1044,7 +1044,7 @@ def visitModule(self, mod): } PyObject *dict = NULL, *fields = NULL, *remaining_fields = NULL, - *positional_args = NULL; + *remaining_dict = NULL, *positional_args = NULL; if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) { return NULL; } @@ -1054,7 +1054,6 @@ def visitModule(self, mod): // serialize them as a dict, during unpickling they are set only *after* // the object is constructed, which will now trigger a DeprecationWarning // if the AST type has required fields. - PyObject *fields = NULL; if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) { goto cleanup; } @@ -1064,12 +1063,12 @@ def visitModule(self, mod): Py_DECREF(dict); goto cleanup; } - PyObject *remaining_dict = PyDict_Copy(dict); + remaining_dict = PyDict_Copy(dict); Py_DECREF(dict); if (!remaining_dict) { goto cleanup; } - PyObject *positional_args = PyList_New(0); + positional_args = PyList_New(0); if (!positional_args) { goto cleanup; } @@ -1097,7 +1096,7 @@ def visitModule(self, mod): if (!args_tuple) { goto cleanup; } - result = Py_BuildValue("ONN", Py_TYPE(self), args_tuple, + result = Py_BuildValue("ONO", Py_TYPE(self), args_tuple, remaining_dict); } else { @@ -1110,6 +1109,7 @@ def visitModule(self, mod): cleanup: Py_XDECREF(fields); Py_XDECREF(remaining_fields); + Py_XDECREF(remaining_dict); Py_XDECREF(positional_args); return result; } diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 7de9c899a95e39..ff3affce94e089 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -5167,7 +5167,7 @@ ast_type_reduce(PyObject *self, PyObject *unused) } PyObject *dict = NULL, *fields = NULL, *remaining_fields = NULL, - *positional_args = NULL; + *remaining_dict = NULL, *positional_args = NULL; if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) { return NULL; } @@ -5177,7 +5177,6 @@ ast_type_reduce(PyObject *self, PyObject *unused) // serialize them as a dict, during unpickling they are set only *after* // the object is constructed, which will now trigger a DeprecationWarning // if the AST type has required fields. - PyObject *fields = NULL; if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) { goto cleanup; } @@ -5187,12 +5186,12 @@ ast_type_reduce(PyObject *self, PyObject *unused) Py_DECREF(dict); goto cleanup; } - PyObject *remaining_dict = PyDict_Copy(dict); + remaining_dict = PyDict_Copy(dict); Py_DECREF(dict); if (!remaining_dict) { goto cleanup; } - PyObject *positional_args = PyList_New(0); + positional_args = PyList_New(0); if (!positional_args) { goto cleanup; } @@ -5220,7 +5219,7 @@ ast_type_reduce(PyObject *self, PyObject *unused) if (!args_tuple) { goto cleanup; } - result = Py_BuildValue("ONN", Py_TYPE(self), args_tuple, + result = Py_BuildValue("ONO", Py_TYPE(self), args_tuple, remaining_dict); } else { @@ -5233,6 +5232,7 @@ ast_type_reduce(PyObject *self, PyObject *unused) cleanup: Py_XDECREF(fields); Py_XDECREF(remaining_fields); + Py_XDECREF(remaining_dict); Py_XDECREF(positional_args); return result; }