[Patches] [ python-Patches-1367711 ] Remove usage of UserDict from os.py

SourceForge.net noreply at sourceforge.net
Mon Jan 16 21:13:01 CET 2006


Patches item #1367711, was opened at 2005-11-27 21:18
Message generated for change (Comment added) made by tds33
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1367711&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
>Priority: 3
Submitted By: Wolfgang Langner (tds33)
Assigned to: Nobody/Anonymous (nobody)
Summary: Remove usage of UserDict from os.py

Initial Comment:
This patch removes UserDict usage from os.py.
It uses the new dict base class instead of UserDict.

Patch was generated against Revision 41544
of python subersion repository.


----------------------------------------------------------------------

>Comment By: Wolfgang Langner (tds33)
Date: 2006-01-16 21:13

Message:
Logged In: YES 
user_id=600792

The intend was to remove dependency on UserDict. Less 
imports for a minimal python. If there are general problems 
with the inheritence from dict than they should be 
documented. I thought in future UserDict will gone.
I investigate this problems.

----------------------------------------------------------------------

Comment By: Armin Rigo (arigo)
Date: 2005-12-29 19:02

Message:
Logged In: YES 
user_id=4771

Subclassing 'dict' to modify some behavior only works more
or less in CPython.  There are a lot of (admitedly
convoluted) ways to get unexpected effects, where the
original methods are called instead of the overridden ones.
And it's not future-proof: if new methods are added to 'dict'
in the future, say a merge() similar to update() but not
replacing existing keys, then they will need to be added to
that subclass as well, or the method will misbehave.  The
advantage of UserDict is to guard against all these problems.

For example, with the patch:

        exec "global a; a=5" in os.environ

stores the key 'a' directly in os.environ, bypassing
the custom __setitem__().  With UserDict instead, we
get an explicit error.  This is more a joke, but the
new-methods-appearing-later problem is more serious
IMHO.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1367711&group_id=5470


More information about the Patches mailing list