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

2021-07-08 Thread Guido van Rossum
Guido van Rossum added the comment: > At worst, this seems like only a minor nuisance. The ABC metaclass is > limited in its powers and seems to reasonably cover the common use cases. > I recommend leaving it as is. Guido, what do you think? Agreed. The abstractness checks are limited

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

2021-07-08 Thread Raymond Hettinger
Raymond Hettinger added the comment: At worst, this seems like only a minor nuisance. The ABC metaclass is limited in its powers and seems to reasonably cover the common use cases. I recommend leaving it as is. Guido, what do you think? -- assignee: -> gvanrossum nosy:

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

2021-07-08 Thread Andrei Kulakov
Andrei Kulakov added the comment: Oops, I see the issue now. I was playing around with the code sample and had the print line commented out inadvertently when I made the output I pasted above. Sorry for the noise! -- ___ Python tracker

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

2021-07-08 Thread Andrei Kulakov
Andrei Kulakov added the comment: I missed the fact that instance was being indeed created, I can see it now. -- ___ Python tracker ___

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

2021-07-08 Thread Andrei Kulakov
Andrei Kulakov added the comment: Ethan, here is the code I tried with 3.9, and the failure: import abc class Base(abc.ABC): def __init_subclass__(cls, **kwargs): instance = cls() print(f"Created instance of {cls} easily: {instance}") @abc.abstractmethod def

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

2021-07-08 Thread Ethan Furman
Ethan Furman added the comment: Andrei, which code did you try? I'm still seeing the failure (i.e. the class being created) in 3.8 and forward. -- versions: +Python 3.11, Python 3.8, Python 3.9 ___ Python tracker

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

2021-07-08 Thread Andrei Kulakov
Andrei Kulakov 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

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

2021-02-01 Thread Ethan Furman
Ethan Furman added the comment: That patch was rejected in favor of updating Enum to use `__set_name__` to do the final creation of enum members. The same thing could be done for ABC, but I lack the C skills to make it happen. -- ___ Python

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

2021-02-01 Thread Ethan Furman
Change by Ethan Furman : -- Removed message: https://bugs.python.org/msg386099 ___ Python tracker ___ ___ Python-bugs-list mailing

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

2021-02-01 Thread Ethan Furman
Ethan Furman added the comment: That patch was reject in favor of updating Enum to use `__set_name__` to do the final creation of enum members. The same thing could be done for ABC, but I lack the C skills to make it happen. -- assignee: ethan.furman -> superseder:

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

2020-12-28 Thread Ethan Furman
Ethan Furman added the comment: If the patch in issue42775 is committed, this problem will be solved. -- assignee: -> ethan.furman superseder: -> __init_subclass__ should be called in __init__ ___ Python tracker

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

2020-12-24 Thread Ethan Furman
Ethan Furman added the comment: I tried update `abc.py` with the same dance I have to use with `Enum`: def __new__(mcls, name, bases, namespace, **kwargs): # remove current __init_subclass__ so previous one can be found with getattr try: new_init_subclass =

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

2020-12-23 Thread Ethan Furman
Change by Ethan Furman : -- nosy: +ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2020-09-09 Thread Thijs Damsma
Change by Thijs Damsma : -- nosy: +tda versions: +Python 3.8 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2020-03-31 Thread Batuhan Taskaya
Batuhan Taskaya added the comment: __init_subclass__ is called way before (in the type_new, when type is in the process of getting created) the object's __new__ (object_new) (which raises that TypeError). -- ___ Python tracker

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

2020-03-31 Thread Batuhan Taskaya
Change by Batuhan Taskaya : -- Removed message: https://bugs.python.org/msg334467 ___ Python tracker ___ ___ Python-bugs-list

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

2019-01-28 Thread BTaskaya
BTaskaya added the comment: I debugged object.__new__ and i saw the subclass you are trying to initalize doesn't have proper signature of abstract classes (it returns 0 from flags & Py_TPFLAGS_IS_ABSTRACT) However it has __abstractmethods__ entry. Currently i'm trying to find why it is

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

2019-01-25 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +rhettinger, stutzbach ___ Python tracker ___ ___ Python-bugs-list mailing list

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

2019-01-23 Thread Jazeps Basko
New submission from Jazeps Basko : I am creating and registering singleton instances of subclasses of ABC in the ABC's __init_subclass__ and I just noticed that I am able to instantiate even the classes which have abstract methods. import abc class Base(abc.ABC): def