mirror of https://github.com/python/cpython
merge 3.5
This commit is contained in:
commit
4a931adef3
|
@ -2404,12 +2404,14 @@ mutablemapping_update(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
/* first handle args, if any */
|
/* first handle args, if any */
|
||||||
if (len < 0) /* PyObject_Size raised an exception. */
|
if (len < 0) /* PyObject_Size raised an exception. */
|
||||||
return NULL;
|
return NULL;
|
||||||
else if (len > 1) {
|
|
||||||
|
if (len > 1) {
|
||||||
char *msg = "update() takes at most 1 positional argument (%d given)";
|
char *msg = "update() takes at most 1 positional argument (%d given)";
|
||||||
PyErr_Format(PyExc_TypeError, msg, len);
|
PyErr_Format(PyExc_TypeError, msg, len);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (len == 1) {
|
|
||||||
|
|
||||||
PyObject *other = PyTuple_GET_ITEM(args, 0); /* borrowed reference */
|
PyObject *other = PyTuple_GET_ITEM(args, 0); /* borrowed reference */
|
||||||
if (other == NULL)
|
if (other == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2459,13 +2461,11 @@ mutablemapping_update(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* now handle kwargs */
|
/* now handle kwargs */
|
||||||
len = (kwargs != NULL) ? PyObject_Size(kwargs) : 0;
|
len = (kwargs != NULL) ? PyObject_Size(kwargs) : 0;
|
||||||
if (len < 0) /* PyObject_Size raised an exception. */
|
if (len < 0) /* PyObject_Size raised an exception. */
|
||||||
return NULL;
|
return NULL;
|
||||||
else if (len > 0) {
|
|
||||||
PyObject *items;
|
PyObject *items;
|
||||||
if (!PyMapping_Check(kwargs)) {
|
if (!PyMapping_Check(kwargs)) {
|
||||||
PyErr_SetString(PyExc_TypeError, "expected mapping for kwargs");
|
PyErr_SetString(PyExc_TypeError, "expected mapping for kwargs");
|
||||||
|
@ -2478,7 +2478,6 @@ mutablemapping_update(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
Py_DECREF(items);
|
Py_DECREF(items);
|
||||||
if (res == -1)
|
if (res == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue