X-Git-Url: https://git.distorted.org.uk/~mdw/mLib-python/blobdiff_plain/c10e2f23e36cdbb9cb12fd44af4ae51b283f5b3f..fcc8f4ca09d374f3130f5ced3891f455a7eee3cb:/pyke/mapping.c diff --git a/pyke/mapping.c b/pyke/mapping.c index ad02d25..b108178 100644 --- a/pyke/mapping.c +++ b/pyke/mapping.c @@ -848,7 +848,7 @@ end: return (rc); } -static int update_core(PyObject *me, PyObject *map) +int gmap_pyupdate(PyObject *me, PyObject *map) { const gmap_ops *gmops = GMAP_OPS(me); PyObject *i = 0, *item = 0, *k = 0, *v = 0; @@ -856,6 +856,7 @@ static int update_core(PyObject *me, PyObject *map) unsigned foundp; int rc = -1; + if (!map) return (0); v = PyObject_CallMethod(map, PY23("iteritems", "items"), 0); #ifdef PY3 if (v) { i = PyObject_GetIter(v); Py_DECREF(v); v = 0; } @@ -899,8 +900,8 @@ PyObject *gmapmeth_update(PyObject *me, PyObject *arg, PyObject *kw) PyObject *map = 0; if (!PyArg_ParseTuple(arg, "|O:update", &map)) return (0); - if (map && update_core(me, map)) return (0); - if (kw && update_core(me, kw)) return (0); + if (gmap_pyupdate(me, map)) return (0); + if (gmap_pyupdate(me, kw)) return (0); RETURN_ME; }