Issue 22487: ABC register doesn't check abstract methods (original) (raw)
Issue22487
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) * ![]() |
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:08 | admin | set | github: 66677 |
2014-09-24 22:00:59 | r.david.murray | set | status: open -> closednosy: + r.david.murraymessages: + resolution: not a bugstage: resolved |
2014-09-24 21:41:32 | rmccampbell7 | set | messages: + |
2014-09-24 21:37:14 | rmccampbell7 | create |