Author eric.araujo
Recipients Kain94, eric.araujo, georg.brandl, r.david.murray, rhettinger, stutzbach, terry.reedy, ysj.ray
Date 2011-02-16.16:35:01
SpamBayes Score 6.0424e-08
Marked as misclassified No
Message-id <1297874103.83.0.593890703113.issue9523@psf.upfronthosting.co.za>
In-reply-to
Content
> Here is my updated patch:
You don’t have to attach a file here, just update the codereview page instead.  Or maybe you can’t because I created the page?

> 1, Now the dbm view objects are the same as dict view objects, which
> are in conformity with collections.KeysView, ValuesView and ItemsView.
Great!  Just to make sure: How do you know that the view objects are compliant?  Do you test all the methods documented for the ABCs?

> 2, I register all these abcs explicitly because these abcs have not
> __subclasshook__() method so they can't check api conformance(at
> lease exist) through isinstance(). I could not make sure api
> conformance except testing each method I find in abc explicitly. And
> my test_abc() is just to test the registering.

Thank you for repeating that many times and politely: I was indeed wrong.  I went back to  PEP 3119 to read again about __instancecheck__ and __subclasscheck__, then experimented in a shell and was surprised.  I have been misunderstanding one thing: issubclass(cls, abc) does not return true automatically if cls provides the methods, it’s entirely up to the ABC to check methods or do something else in its __subclasscheck__ or __instancecheck__ methods.  (I should have known better, I was in a discussion about adding that very feature on python-ideas and #9731!)  After another bit of experimentation with dict views and collections ABCs, I finally understand that you have to register your view classes.  Thanks for letting me correct my misunderstanding.
History
Date User Action Args
2011-02-16 16:35:03eric.araujosetrecipients: + eric.araujo, georg.brandl, rhettinger, terry.reedy, stutzbach, r.david.murray, Kain94, ysj.ray
2011-02-16 16:35:03eric.araujosetmessageid: <1297874103.83.0.593890703113.issue9523@psf.upfronthosting.co.za>
2011-02-16 16:35:01eric.araujolinkissue9523 messages
2011-02-16 16:35:01eric.araujocreate