Skip to content

Wtf8-compatible fixes #5985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 29, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix PyBoundMethod::repr
  • Loading branch information
youknowone committed Jul 29, 2025
commit 9c649eb9c2672a0d4509b6f000f1f7e7367fbefa
9 changes: 6 additions & 3 deletions vm/src/builtins/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,10 +859,13 @@ impl Representable for PyBoundMethod {
vm.get_attribute_opt(zelf.function.clone(), "__name__")?
};
let func_name: Option<PyStrRef> = func_name.and_then(|o| o.downcast().ok());
let formatted_func_name = match func_name {
Some(name) => name.to_string(),
None => "?".to_string(),
};
let object_repr = zelf.object.repr(vm)?;
Ok(format!(
"<bound method {} of {}>",
func_name.as_ref().map_or("?", |s| s.as_str()),
&zelf.object.repr(vm)?.as_str(),
"<bound method {formatted_func_name} of {object_repr}>",
))
}
}
Expand Down