Skip to content

Commit 11a6635

Browse files
authored
Merge pull request RustPython#1967 from youknowone/fix-dict-errmsg
Fix object.__dict__ error message
2 parents 31c9947 + cae1d5f commit 11a6635

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

vm/src/obj/objobject.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,12 @@ impl PyBaseObject {
187187

188188
#[pyproperty(magic)]
189189
fn dict(object: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyDictRef> {
190-
object
191-
.dict()
192-
.ok_or_else(|| vm.new_attribute_error("no dictionary.".to_owned()))
190+
object.dict().ok_or_else(|| {
191+
vm.new_attribute_error(format!(
192+
"'{}' object has no attribute '__dict__'",
193+
object.class().name
194+
))
195+
})
193196
}
194197

195198
#[pyproperty(magic, setter)]

0 commit comments

Comments
 (0)