Skip to content

Commit 27a52a7

Browse files
hydrogen602youknowone
authored andcommitted
test_class.py: testTypeAttributeAccessErrorMessages fix
1 parent 61feb43 commit 27a52a7

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

‎Lib/test/test_class.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,6 @@ class A:
629629
with self.assertRaises(TypeError):
630630
type.__setattr__(A, b'x', None)
631631

632-
# TODO: RUSTPYTHON
633-
@unittest.expectedFailure
634632
def testTypeAttributeAccessErrorMessages(self):
635633
class A:
636634
pass

‎vm/src/builtins/type.rs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,10 +1082,11 @@ impl SetAttr for PyType {
10821082
} else {
10831083
let prev_value = zelf.attributes.write().shift_remove(attr_name); // TODO: swap_remove applicable?
10841084
if prev_value.is_none() {
1085-
return Err(vm.new_exception(
1086-
vm.ctx.exceptions.attribute_error.to_owned(),
1087-
vec![attr_name.to_object()],
1088-
));
1085+
return Err(vm.new_attribute_error(format!(
1086+
"type object '{}' has no attribute '{}'",
1087+
zelf.name(),
1088+
attr_name.as_str(),
1089+
)));
10891090
}
10901091
}
10911092
if attr_name.as_str().starts_with("__") && attr_name.as_str().ends_with("__") {

0 commit comments

Comments
 (0)