This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ping
Recipients
Date 2001-04-02.17:18:02
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The methods 'get', 'setdefault', and 'update'
on a dictionary are usually implemented (and
thought of) in terms of the lower-level methods
has_key, __getitem__, and __setitem__.  The
current implementation of UserDict relays a
call to e.g. x.get() to x.data.get(), which
behaves inconsistently if __getitem__ has been
implemented on x.

One particular big place where this turns up is cgi.
If you get a dict = cgi.SvFormContentDict(), then
dict.get('key') will return a *list* even though
dict['key'] returns a single item!

To make UserDict behave consistently, this patch
fixes get(), update(), and setdefault() to re-use
the other methods.  Then the only occurrence of
self.data[k] = v is in __setitem__, the only
occurrence of self.data[k] without assignment is
in __getitem__, etc.
History
Date User Action Args
2007-08-23 15:04:35adminlinkissue413171 messages
2007-08-23 15:04:35admincreate