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.

Title: ABC register doesn't check abstract methods
Type: enhancement Stage: resolved
Components: Versions:
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.
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