Commit 01fb5d0b authored by Marius Wachtler's avatar Marius Wachtler

don't crash when deleting nonexisting instance attributes

parent 1f4a1b09
......@@ -587,7 +587,14 @@ Box* instanceDelattr(Box* _inst, Box* _attr) {
return runtimeCall(delattr, ArgPassSpec(1), _attr, NULL, NULL, NULL, NULL);
}
_inst->delattr(attr, NULL);
if (_inst->hasattr(attr))
_inst->delattr(attr, NULL);
else {
BoxedClassobj* clsobj = (BoxedClassobj*)inst->inst_cls;
RELEASE_ASSERT(PyClass_Check(clsobj), "");
raiseExcHelper(AttributeError, "%.50s instance has no attribute '%.400s'", clsobj->name->c_str(),
attr->c_str());
}
return None;
}
......
......@@ -387,6 +387,10 @@ try:
C.doesnt_exist
except AttributeError as e:
print e
try:
del C().doesnt_exist
except AttributeError as e:
print e
class C():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment