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 rhettinger
Recipients eric.frederich, eric.snow, rhettinger
Date 2015-07-24.01:33:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1437701604.12.0.0877678521078.issue24685@psf.upfronthosting.co.za>
In-reply-to
Content
Eric, I believe you're profoundly misunderstanding my Pycon talk.  The posted code is not expected "to work if I swap the order of the classes around" -- MRO's are controlled by the child classes (subject to a number of constraints) and the order classes are listed matters greatly.  Also, cooperative classes have to be designed cooperatively.  The standard library OD class was intentionally tightly bound to its parent class to provide opportunities for a C implementation, to provide acceptable performance, and to make it easier for Jython and PyPy to implement the OD in ways favorable to their implementations.  Likewise it was intentional to hide access to the underlying dict using name mangling for the same reasons (that one was Guido's suggestion).  Also note, Guido's defaultdict also won't let you step in-between the class and its parent.

Also, your posted mal-functioning wrapper is mis-implemented.   Please see the "How to Incorporate a Non-cooperative Class" section of the referenced blog post.  The dependency injection technique is something that be used when testing your own subclasses which were built a loose coupling to a "default supplier" and where the calls between the consumer and supplier are a well defined part of the public API.  Only a handful of standard library tools were meant to be used this way. (That is why I the non-cooperative class integration part of the blog post was necessary).  

I've reclassified the tracker item as a feature request for 3.6.  Without compelling use cases, it will likely be re-rejected shortly. That said, I'm concerned that you've got "a burr under your saddle" and won't take no for an answer, so I'll leave this open for a while to allow you a chance to think about it and re-close it yourself.  I hope your will understand that we have valid reasons for not over-specifying the API and have a reluctance to tie our hands to the implementation details as the OD gets transitioned to a C implementation suitable internal use within the core.  FWIW, the OD code is pure python and there's nothing stopping you from using your own variants.
History
Date User Action Args
2015-07-24 01:33:24rhettingersetrecipients: + rhettinger, eric.snow, eric.frederich
2015-07-24 01:33:24rhettingersetmessageid: <1437701604.12.0.0877678521078.issue24685@psf.upfronthosting.co.za>
2015-07-24 01:33:24rhettingerlinkissue24685 messages
2015-07-24 01:33:21rhettingercreate