Adds __qualname__ to PyBuiltinFunction

This commit is contained in:
Nikita Sobolev
2021-08-04 07:59:40 +03:00
committed by GitHub
parent fa8072cfd6
commit 8f2679a97a
2 changed files with 18 additions and 0 deletions

View File

@@ -109,3 +109,17 @@ assert MyTypeWithMethod().N.s.__qualname__ == 'MyTypeWithMethod.N.s'
assert repr(str.replace) == "<method 'replace' of 'str' objects>"
assert repr(str.replace) == str(str.replace)
assert repr(int.to_bytes) == "<method 'to_bytes' of 'int' objects>"
# Regression to
# https://github.com/RustPython/RustPython/issues/2788
assert iter.__qualname__ == iter.__name__ == 'iter'
assert max.__qualname__ == max.__name__ == 'max'
assert min.__qualname__ == min.__name__ == 'min'
def custom_func():
pass
assert custom_func.__qualname__ == 'custom_func'

View File

@@ -118,6 +118,10 @@ impl PyBuiltinFunction {
self.value.name.clone()
}
#[pyproperty(magic)]
fn qualname(&self) -> PyStrRef {
self.name()
}
#[pyproperty(magic)]
fn doc(&self) -> Option<PyStrRef> {
self.value.doc.clone()
}