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 jimjjewett
Recipients aronacher, georg.brandl, jimjjewett, pitrou, rhettinger
Date 2009-03-02.04:10:51
SpamBayes Score 1.1786592e-07
Marked as misclassified No
Message-id <1235967055.01.0.234624648736.issue5402@psf.upfronthosting.co.za>
In-reply-to
Content
Copy of issue 5397

In python 3, UserDict (and DictMixin) are gone; presumably they should 
be replaced by either a dict subclass or the ABC MutableMapping.

Unfortunately, there doesn't seem to be a clean way to inherit from 
both.  

In python 2.x, you could write

  class MyDict(DictMixin, dict): ...

but with

  class MyDict(MutableMapping, dict): ...

MutableMapping explicitly overrides __getitem__, __setitem__, and 
__delitem__ to raise a KeyError.

The OrderedDict implementation in issue 5397 puts the concrete class 
first, and then handles composite methods manually, by either rewriting 
them (repr, copy) or explicitly delegating past dict and straight to 
MutableMapping (setdefault, update, etc.)

Both solutions seem fragile.  

Unfortunately, the closest I come to a solution is to split the ABC 
into a Mixin portion and an ABC enforcer.

    # The concrete methods of the current ABC
    class MapMixin: 

    # The abstract methods that get checked
    class MutableMapping(MapMixin):

# Trust that dict will always implement 
# all required concrete methods for us
class MyDict(MapMixin, dict):
History
Date User Action Args
2009-03-02 04:10:55jimjjewettsetrecipients: + jimjjewett, georg.brandl, rhettinger, pitrou, aronacher
2009-03-02 04:10:55jimjjewettsetmessageid: <1235967055.01.0.234624648736.issue5402@psf.upfronthosting.co.za>
2009-03-02 04:10:52jimjjewettlinkissue5402 messages
2009-03-02 04:10:51jimjjewettcreate