summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 779746a..b20b85c 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -2183,16 +2183,25 @@ dict_update_common(PyObject *self, PyObject *args, PyObject *kwds,
PyObject *arg = NULL;
int result = 0;
- if (!PyArg_UnpackTuple(args, methname, 0, 1, &arg))
+ if (!PyArg_UnpackTuple(args, methname, 0, 1, &arg)) {
result = -1;
-
+ }
else if (arg != NULL) {
_Py_IDENTIFIER(keys);
- if (_PyObject_HasAttrId(arg, &PyId_keys))
+ PyObject *func = _PyObject_GetAttrId(arg, &PyId_keys);
+ if (func != NULL) {
+ Py_DECREF(func);
result = PyDict_Merge(self, arg, 1);
- else
+ }
+ else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
+ PyErr_Clear();
result = PyDict_MergeFromSeq2(self, arg, 1);
+ }
+ else {
+ result = -1;
+ }
}
+
if (result == 0 && kwds != NULL) {
if (PyArg_ValidateKeywordArguments(kwds))
result = PyDict_Merge(self, kwds, 1);