homepage

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.

classification
Title: ABC register doesn't check abstract methods
Type: enhancement Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: r.david.murray, rmccampbell7
Priority: normal Keywords:

Created on 2014年09月24日 21:37 by rmccampbell7, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Messages (3)
msg227489 - (view) Author: Ryan McCampbell (rmccampbell7) Date: 2014年09月24日 21:37
Is there a reason register() doesn't check for abstract methods, like subclassing does? Would it fail for some builtin classes? It seems that this would be a better guarantee that, say, something really is iterable when you check isinstance(Collections.Iterable, o), since someone could have called Collections.Iterable.register(o.__class__) without adding an __iter__ method to their class.
msg227490 - (view) Author: Ryan McCampbell (rmccampbell7) Date: 2014年09月24日 21:41
Obviously, I meant isinstance(o, Collections.Iterable).
msg227491 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014年09月24日 22:00
Python is a consenting adults language. If you call register, we assume you know what you are doing. The isinstance check, on the other hand, does look in certain cases. So if you define __iter__ you don't have to call register to make isinstance(o, Iterable) be True.
History
Date User Action Args
2022年04月11日 14:58:08adminsetgithub: 66677
2014年09月24日 22:00:59r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg227491

resolution: not a bug
stage: resolved
2014年09月24日 21:41:32rmccampbell7setmessages: + msg227490
2014年09月24日 21:37:14rmccampbell7create

AltStyle によって変換されたページ (->オリジナル) /