mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-108511: Add C API functions which do not silently ignore errors (GH-109025)
Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
This commit is contained in:
parent
e57ecf6bbc
commit
add16f1a5e
28 changed files with 330 additions and 111 deletions
|
@ -2688,12 +2688,11 @@ dict_update_arg(PyObject *self, PyObject *arg)
|
|||
if (PyDict_CheckExact(arg)) {
|
||||
return PyDict_Merge(self, arg, 1);
|
||||
}
|
||||
PyObject *func;
|
||||
if (PyObject_GetOptionalAttr(arg, &_Py_ID(keys), &func) < 0) {
|
||||
int has_keys = PyObject_HasAttrWithError(arg, &_Py_ID(keys));
|
||||
if (has_keys < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (func != NULL) {
|
||||
Py_DECREF(func);
|
||||
if (has_keys) {
|
||||
return PyDict_Merge(self, arg, 1);
|
||||
}
|
||||
return PyDict_MergeFromSeq2(self, arg, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue