mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +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
|
@ -1004,9 +1004,13 @@ module_set_annotations(PyModuleObject *m, PyObject *value, void *Py_UNUSED(ignor
|
|||
}
|
||||
else {
|
||||
/* delete */
|
||||
ret = PyDict_DelItem(dict, &_Py_ID(__annotations__));
|
||||
if (ret < 0 && PyErr_ExceptionMatches(PyExc_KeyError)) {
|
||||
PyErr_SetString(PyExc_AttributeError, "__annotations__");
|
||||
ret = PyDict_Pop(dict, &_Py_ID(__annotations__), NULL);
|
||||
if (ret == 0) {
|
||||
PyErr_SetObject(PyExc_AttributeError, &_Py_ID(__annotations__));
|
||||
ret = -1;
|
||||
}
|
||||
else if (ret > 0) {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue