Commit d1eb84d5 authored by Rudi Chen's avatar Rudi Chen

Make sure to intern attribute string in PyObject_SetAttr.

parent 07f0a1aa
...@@ -445,12 +445,15 @@ extern "C" int PyObject_SetAttr(PyObject* obj, PyObject* name, PyObject* value) ...@@ -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)); assert(PyString_Check(name));
try { try {
if (value == NULL) if (value == NULL)
delattr(obj, static_cast<BoxedString*>(name)); delattr(obj, name_str);
else else
setattr(obj, static_cast<BoxedString*>(name), value); setattr(obj, name_str, value);
} catch (ExcInfo e) { } catch (ExcInfo e) {
setCAPIException(e); setCAPIException(e);
return -1; return -1;
......
...@@ -101,3 +101,12 @@ def f14(): ...@@ -101,3 +101,12 @@ def f14():
except Exception: except Exception:
pass pass
f14() 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