Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1fb6088

Browse files
committed
dict_update has two boundary conditions: a.update(a) and a.update({})
Added test for second one.
1 parent db60bb5 commit 1fb6088

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Objects/dictobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,8 @@ dict_update(register dictobject *mp, PyObject *args)
809809
dictentry *entry;
810810
if (!PyArg_Parse(args, "O!", &PyDict_Type, &other))
811811
return NULL;
812-
if (other == mp)
813-
goto done; /* a.update(a); nothing to do */
812+
if (other == mp || other->ma_used == 0)
813+
goto done; /* a.update(a) or a.update({}); nothing to do */
814814
/* Do one big resize at the start, rather than incrementally
815815
resizing as we insert new items. Expect that there will be
816816
no (or few) overlapping keys. */

0 commit comments

Comments
 (0)