[Python-Dev] Re: Make __mro_entries__ mandatory for non-types

2022-03-05 Thread Jason Madden
Steven D'Aprano wrote: > On Sat, Mar 05, 2022 at 04:42:55PM -, Jason Madden wrote: > > zope.interface relies on this behaviour. > > The example you give shows that Interface is a class. It merely has a > metaclass which is not `type`. (I presume that is what's going on > behind the scenes.)

[Python-Dev] Re: Make __mro_entries__ mandatory for non-types

2022-03-05 Thread Guido van Rossum
Yes, it's supposed to work. There's tons of special code to support it, and documentation (e.g. https://docs.python.org/3/reference/datamodel.html?highlight=__mro_entries__#resolving-mro-entries ). Now, I think it was an attempt at getting too fancy, but we can't remove the functionality without d

[Python-Dev] Re: Make __mro_entries__ mandatory for non-types

2022-03-05 Thread Steven D'Aprano
On Sat, Mar 05, 2022 at 04:42:55PM -, Jason Madden wrote: > zope.interface relies on this behaviour. The example you give shows that Interface is a class. It merely has a metaclass which is not `type`. (I presume that is what's going on behind the scenes.) I'm asking about the example that

[Python-Dev] Re: Make __mro_entries__ mandatory for non-types

2022-03-05 Thread Guido van Rossum
Good to hear from you, Serhiy. I hope you and your family are safe. On Sat, Mar 5, 2022 at 1:29 AM Serhiy Storchaka wrote: > Currently the class can inherit from arbitrary objects, not only types. > If the object was not designed for this you can get a mysterious > mistake, e g.: > > >>> class

[Python-Dev] Re: Make __mro_entries__ mandatory for non-types

2022-03-05 Thread Jason Madden
Steven D'Aprano wrote: > On Sat, Mar 05, 2022 at 11:27:44AM +0200, Serhiy Storchaka wrote: > > Currently the class can inherit from arbitrary objects, not only types. > > Is that intentionally supported? > I know that metaclasses do not have to be actual classes, they can be > any callable with th

[Python-Dev] Re: Make __mro_entries__ mandatory for non-types

2022-03-05 Thread Steven D'Aprano
On Sat, Mar 05, 2022 at 11:27:44AM +0200, Serhiy Storchaka wrote: > Currently the class can inherit from arbitrary objects, not only types. Is that intentionally supported? I know that metaclasses do not have to be actual classes, they can be any callable with the correct signature, but I didn

[Python-Dev] Make __mro_entries__ mandatory for non-types

2022-03-05 Thread Serhiy Storchaka
Currently the class can inherit from arbitrary objects, not only types. If the object was not designed for this you can get a mysterious mistake, e g.: >>> class A(1): ... ... Traceback (most recent call last): File "", line 1, in TypeError: int() takes at most 2 arguments (3 given) If the