Message36252
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. |
|
Date |
User |
Action |
Args |
2007-08-23 15:04:35 | admin | link | issue413171 messages |
2007-08-23 15:04:35 | admin | create | |
|