Commit 885046a2 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #744 from rudi-c/fix_setstate

Make sure to intern attribute string in PyObject_SetAttr.
parents e6893159 d1eb84d5
......@@ -445,12 +445,15 @@ extern "C" int PyObject_SetAttr(PyObject* obj, PyObject* name, PyObject* value)
}
}
BoxedString* name_str = static_cast<BoxedString*>(name);
internStringMortalInplace(name_str);
assert(PyString_Check(name));
try {
if (value == NULL)
delattr(obj, static_cast<BoxedString*>(name));
delattr(obj, name_str);
else
setattr(obj, static_cast<BoxedString*>(name), value);
setattr(obj, name_str, value);
} catch (ExcInfo e) {
setCAPIException(e);
return -1;
......
......@@ -101,3 +101,12 @@ def f14():
except Exception:
pass
f14()
def test_set_state():
exc = BaseException()
print exc.__dict__
attrs = {"x": 1, "y": 2}
exc.__setstate__(attrs)
print exc.__dict__ == attrs
test_set_state()
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