]> granicus.if.org Git - python/commitdiff
dict_update has two boundary conditions: a.update(a) and a.update({})
authorJeremy Hylton <jeremy@alum.mit.edu>
Wed, 3 Jan 2001 22:34:59 +0000 (22:34 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Wed, 3 Jan 2001 22:34:59 +0000 (22:34 +0000)
Added test for second one.

Objects/dictobject.c

index 42e270edc1a8b8f3c4874faba8bd2030cb83c8eb..9398d0dbffc4544d8f15e2cd3e70549a1f168ac1 100644 (file)
@@ -809,8 +809,8 @@ dict_update(register dictobject *mp, PyObject *args)
         dictentry *entry;
        if (!PyArg_Parse(args, "O!", &PyDict_Type, &other))
                return NULL;
-       if (other == mp)
-               goto done; /* a.update(a); nothing to do */
+       if (other == mp || other->ma_used == 0)
+               goto done; /* a.update(a) or a.update({}); nothing to do */
        /* Do one big resize at the start, rather than incrementally
           resizing as we insert new items.  Expect that there will be
           no (or few) overlapping keys. */