This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Cryptic error message when creating types that don't include themselves in their MRO
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.9, Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ppperry, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-02-17 17:00 by ppperry, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg362152 - (view) Author: (ppperry) Date: 2020-02-17 17:00
I was trying to create a class that didn't have any references to itself to test issue39382 and ran the following code:

class Meta(type):
	def mro(cls):
		return type.mro(cls)[1:]
class X(metaclass=Meta):
	    pass

This produced an extremely cryptic error message:

Traceback (most recent call last):
  File "<pyshell#89>", line 1, in <module>
    class X(metaclass=Meta):
TypeError: super(type, obj): obj must be an instance or subtype of type

While what I am trying to do may well not be supported, the error message referencing the `super` function, which I didn't use, is not helpful.
msg362154 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-02-17 18:26
Yes, I got the same error message when tried to get such class.

super() is called implicitly by the type constructor to call __init_subclass__ on the parent of a newly generated type.
History
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83846
2020-03-26 00:03:35ppperrysetcomponents: - Build
versions: + Python 3.9
2020-02-17 18:26:45serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg362154
2020-02-17 17:00:26ppperrycreate