forked from Rust-related/RustPython
Merge pull request #1433 from pitachips/call_error_message
fix error message for __call__ for non-callable objects
This commit is contained in:
@@ -603,10 +603,13 @@ impl VirtualMachine {
|
||||
self.invoke(&function, args.insert(object.clone()))
|
||||
} else if let Some(PyBuiltinFunction { ref value }) = func_ref.payload() {
|
||||
value(self, args)
|
||||
} else {
|
||||
// TODO: is it safe to just invoke __call__ otherwise?
|
||||
vm_trace!("invoke __call__ for: {:?}", &func_ref.payload);
|
||||
} else if self.is_callable(&func_ref) {
|
||||
self.call_method(&func_ref, "__call__", args)
|
||||
} else {
|
||||
Err(self.new_type_error(format!(
|
||||
"'{}' object is not callable",
|
||||
func_ref.class().name
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user