]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
dict_update(): Generalize this method so {}.update() accepts any
authorBarry Warsaw <barry@python.org>
Tue, 26 Jun 2001 20:08:32 +0000 (20:08 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 26 Jun 2001 20:08:32 +0000 (20:08 +0000)
commit66a0d1d9b9f7d7e3bd7edce79bf862fc4cdd7b01
treed558727415d5663d76dec08adce6ecebdbbd7534
parent0dcf67e56d891832b53a82ee0abb60dcc2e0148e
dict_update(): Generalize this method so {}.update() accepts any
"mapping" object, specifically one that supports PyMapping_Keys() and
PyObject_GetItem().  This allows you to say e.g. {}.update(UserDict())

We keep the special case for concrete dict objects, although that
seems moderately questionable.  OTOH, the code exists and works, so
why change that?

.update()'s docstring already claims that D.update(E) implies calling
E.keys() so it's appropriate not to transform AttributeErrors in
PyMapping_Keys() to TypeErrors.

Patch eyeballed by Tim.
Objects/dictobject.c