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 "<stdin>", line 1, in <module>
TypeError: int() takes at most 2 arguments (3 given)
If the object's constructor is compatible with type constructor by
accident you can an unexpected result. To prevent this we usually add an
explicit __mro_entries__() method which raises an exception.
I propose to make __mro_entries__() mandatory if a base is not a type
instance (with a deprecation period).
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/QDFG65U5ILB7LISC7UL2WFGQIAL2DMUV/
Code of Conduct: http://python.org/psf/codeofconduct/
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 "<stdin>", line 1, in <module>
TypeError: int() takes at most 2 arguments (3 given)
If the object's constructor is compatible with type constructor by
accident you can an unexpected result. To prevent this we usually add an
explicit __mro_entries__() method which raises an exception.
I propose to make __mro_entries__() mandatory if a base is not a type
instance (with a deprecation period).
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/QDFG65U5ILB7LISC7UL2WFGQIAL2DMUV/
Code of Conduct: http://python.org/psf/codeofconduct/