[issue1367711] Remove usage of UserDict from os.py

Andrew Dalke report at bugs.python.org
Sat Jan 12 12:30:55 CET 2008


Andrew Dalke added the comment:

I was optimization tuning and wondered why UserDict was imported by os.  Replacing 
UserDict with dict passes all existing regression tests.

I see the concerns that doing that replacement is not future proof.  Strange then 
that Cookie.py is acceptable.  There are three places in Lib which derive from dict, 
and two are in Cookie.py and in both cases it's broken because set_default does not 
go through the same checks that __setitem__ goes through.

(The other place is an internal class in _strptime.)

In looking over existing third-party code, I see this nuance of when to use UserDict 
vs. dict isn't that well known.  The documentation says "The need for this class has 
been largely supplanted by the ability to subclass directly from dict", but that 
isn't true if anyone is worried about future-proofing and where the subclass changes 
one of the standard methods.

----------
nosy: +dalke

_____________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1367711>
_____________________________________


More information about the Python-bugs-list mailing list