The signature is: super([type[, object-or-type]])
. And its doc says:
If the second argument is omitted, the super object returned is unbound. If the second argument is an object,
isinstance(obj, type)
must be true. If the second argument is a type,issubclass(type2, type)
must be true (this is useful for classmethods).
According to the doc, if someone wants super(metatype, type)
, the second argument is a type, so issubclass(type, metatype)
must be true. But my test program shows it can be false:
#!/usr/bin/env python3
class M0(type):
def wtf(self):
print('M0')
class M1(M0):
def wtf(self):
print('M1')
class C0(metaclass=M1):
@classmethod
def wtf(cls):
assert issubclass(C0, M1) == False
super(M1, C0).wtf()
C0.wtf()
Is this guaranteed or undefined?