Éric Araujo <mer...@netwok.org> added the comment: > 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9523> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com