Inheriting from a function produces nonsensical-ish error message
Created originally on Bitbucket by JulianB (Julian Berman)
>>> def foo():
... pass
>>>
>>> class Bar(foo):
... pass
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'internal-code' object expected, got 'str' instead
'internal-code' object expected, got 'str' instead
(CPython is no better, FWIW, on 3.7:
>>> def foo():
... pass
...
>>>
>>> class Bar(foo):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function() argument 1 must be code, not str
)
Something like “superclasses of a class must be instances of type
(i.e. classes)” would be a lot nicer (if in fact that is the criteria, I forget)