Commit a386433c authored by Marius Wachtler's avatar Marius Wachtler

Fix rare problem when deleting attributes of oldstyle classes

I could not find a reliable way to reproduce it and don't fully understand the problem :-(
But it looked like we were sometimes calling into the generic setattr instead of the classobj setattr when doing a delete.
parent 2d0eaa3d
...@@ -296,6 +296,11 @@ static Box* classobjSetattr(Box* _cls, Box* _attr, Box* _value) { ...@@ -296,6 +296,11 @@ static Box* classobjSetattr(Box* _cls, Box* _attr, Box* _value) {
return None; return None;
} }
static Box* classobjDelattr(Box* _cls, Box* _attr) {
_classobjSetattr(_cls, _attr, NULL);
return None;
}
static int classobj_setattro(Box* cls, Box* attr, Box* value) noexcept { static int classobj_setattro(Box* cls, Box* attr, Box* value) noexcept {
try { try {
_classobjSetattr(cls, attr, value); _classobjSetattr(cls, attr, value);
...@@ -1672,6 +1677,8 @@ void setupClassobj() { ...@@ -1672,6 +1677,8 @@ void setupClassobj() {
new BoxedFunction(FunctionMetadata::create((void*)classobjGetattribute, UNKNOWN, 2))); new BoxedFunction(FunctionMetadata::create((void*)classobjGetattribute, UNKNOWN, 2)));
classobj_cls->giveAttr("__setattr__", classobj_cls->giveAttr("__setattr__",
new BoxedFunction(FunctionMetadata::create((void*)classobjSetattr, UNKNOWN, 3))); new BoxedFunction(FunctionMetadata::create((void*)classobjSetattr, UNKNOWN, 3)));
classobj_cls->giveAttr("__delattr__",
new BoxedFunction(FunctionMetadata::create((void*)classobjDelattr, UNKNOWN, 2)));
classobj_cls->giveAttr("__str__", new BoxedFunction(FunctionMetadata::create((void*)classobjStr, STR, 1))); classobj_cls->giveAttr("__str__", new BoxedFunction(FunctionMetadata::create((void*)classobjStr, STR, 1)));
classobj_cls->giveAttr("__repr__", new BoxedFunction(FunctionMetadata::create((void*)classobjRepr, STR, 1))); classobj_cls->giveAttr("__repr__", new BoxedFunction(FunctionMetadata::create((void*)classobjRepr, STR, 1)));
classobj_cls->giveAttr("__dict__", dict_descr); classobj_cls->giveAttr("__dict__", dict_descr);
......
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