Adds __subclasshook__ to type, refs #2794

This commit is contained in:
sobolevn
2021-08-09 16:33:57 +03:00
parent 81200b12f4
commit c0f38e2263
2 changed files with 12 additions and 0 deletions

View File

@@ -151,3 +151,10 @@ assert BaseException.args.__qualname__ == 'BaseException.args'
assert Exception.args.__qualname__ == 'BaseException.args'
# dynamic with `.new_readonly_getset`
assert SyntaxError.msg.__qualname__ == 'SyntaxError.msg'
# Regression to
# https://github.com/RustPython/RustPython/issues/2794
assert type.__subclasshook__.__qualname__ == 'type.__subclasshook__'
assert object.__subclasshook__.__qualname__ == 'object.__subclasshook__'

View File

@@ -290,6 +290,11 @@ impl PyType {
subclass.issubclass(&zelf)
}
#[pyclassmethod(magic)]
fn subclasshook(_args: FuncArgs, vm: &VirtualMachine) -> PyObjectRef {
vm.ctx.not_implemented()
}
#[pyproperty(magic)]
fn name(&self) -> String {
self.name.clone()