mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Refactor function repr
This commit is contained in:
@@ -410,17 +410,8 @@ impl PyFunction {
|
||||
}
|
||||
|
||||
#[pymethod(magic)]
|
||||
fn repr(zelf: PyRef<Self>, vm: &VirtualMachine) -> String {
|
||||
let qualname = zelf
|
||||
.as_object()
|
||||
.to_owned()
|
||||
.get_attr("__qualname__", vm)
|
||||
.ok()
|
||||
.and_then(|qualname_attr| qualname_attr.downcast::<PyStr>().ok())
|
||||
.map(|qualname| qualname.as_str().to_owned())
|
||||
.unwrap_or_else(|| zelf.name().as_str().to_owned());
|
||||
|
||||
format!("<function {} at {:#x}>", qualname, zelf.get_id())
|
||||
fn repr(zelf: PyRef<Self>) -> String {
|
||||
format!("<function {} at {:#x}>", zelf.qualname(), zelf.get_id())
|
||||
}
|
||||
|
||||
#[cfg(feature = "jit")]
|
||||
|
||||
Reference in New Issue
Block a user