mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438)
This commit is contained in:
parent
882fcede83
commit
72d3cc94cd
15 changed files with 116 additions and 119 deletions
18
Python/Python-ast.c
generated
18
Python/Python-ast.c
generated
|
@ -5223,20 +5223,20 @@ ast_type_reduce(PyObject *self, PyObject *unused)
|
|||
if (!name) {
|
||||
goto cleanup;
|
||||
}
|
||||
PyObject *value = PyDict_GetItemWithError(remaining_dict, name);
|
||||
PyObject *value;
|
||||
int rc = PyDict_Pop(remaining_dict, name, &value);
|
||||
Py_DECREF(name);
|
||||
if (rc < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
if (!value) {
|
||||
if (PyErr_Occurred()) {
|
||||
goto cleanup;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (PyList_Append(positional_args, value) < 0) {
|
||||
rc = PyList_Append(positional_args, value);
|
||||
Py_DECREF(value);
|
||||
if (rc < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
if (PyDict_DelItem(remaining_dict, name) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
Py_DECREF(name);
|
||||
}
|
||||
PyObject *args_tuple = PyList_AsTuple(positional_args);
|
||||
if (!args_tuple) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue