test_class.py: testTypeAttributeAccessErrorMessages fix

This commit is contained in:
hydrogen602
2024-05-13 01:55:32 -05:00
committed by Jeong, YunWon
parent 61feb43aba
commit 27a52a7962
2 changed files with 5 additions and 6 deletions

View File

@@ -629,8 +629,6 @@ class ClassTests(unittest.TestCase):
with self.assertRaises(TypeError):
type.__setattr__(A, b'x', None)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def testTypeAttributeAccessErrorMessages(self):
class A:
pass

View File

@@ -1082,10 +1082,11 @@ impl SetAttr for PyType {
} else {
let prev_value = zelf.attributes.write().shift_remove(attr_name); // TODO: swap_remove applicable?
if prev_value.is_none() {
return Err(vm.new_exception(
vm.ctx.exceptions.attribute_error.to_owned(),
vec![attr_name.to_object()],
));
return Err(vm.new_attribute_error(format!(
"type object '{}' has no attribute '{}'",
zelf.name(),
attr_name.as_str(),
)));
}
}
if attr_name.as_str().starts_with("__") && attr_name.as_str().ends_with("__") {