Commit 7a8ca7b0 authored by Stefan Behnel's avatar Stefan Behnel

widen mapping-like object support when merging them into a kwargs dict

parent 72bdc071
......@@ -317,7 +317,22 @@ static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping) {
Py_ssize_t orig_length, ppos = 0;
iter = __Pyx_dict_iterator(source_mapping, 0, PYIDENT("items"), &orig_length, &source_is_dict);
if (unlikely(!iter)) goto bad;
if (unlikely(!iter)) {
// slow fallback: try converting to dict, then iterate
PyObject *args;
if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
PyErr_Clear();
args = PyTuple_Pack(1, source_mapping);
if (likely(args)) {
PyObject *fallback = PyObject_Call((PyObject*)&PyDict_Type, args, NULL);
Py_DECREF(args);
if (likely(fallback)) {
iter = __Pyx_dict_iterator(fallback, 1, PYIDENT("items"), &orig_length, &source_is_dict);
Py_DECREF(fallback);
}
}
if (unlikely(!iter)) goto bad;
}
while (1) {
result = __Pyx_dict_iter_next(iter, orig_length, &ppos, &key, &value, NULL, source_is_dict);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment