[issue35815] Able to instantiate a subclass with abstract methods from __init_subclass__ of the ABC

Andrei Kulakov report at bugs.python.org
Thu Jul 8 09:51:33 EDT 2021


Andrei Kulakov <andrei.avk at gmail.com> added the comment:

Ethan: as far as I understand, there's no actual problem here. The report adds a print statement in __init_subclass__ that says that instance was created, while in fact instance is not created. I can confirm what Batuhan said, in my testing, that it fails with TypeError as expected:

python3 ~/temp/a.py                                                                                                                                                                                                         ----VICMD----
Created instance of <class '__main__.Derived'> easily: <__main__.Derived object at 0x106fbb9d0>
Traceback (most recent call last):
  File "/Users/ak/temp/a.py", line 54, in <module>
    Derived()
TypeError: Can't instantiate abstract class Derived with abstract method do_something


I think this can be closed as not a bug.

----------
nosy: +andrei.avk

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35815>
_______________________________________


More information about the Python-bugs-list mailing list