Commit e2fdc610 authored by Neal Norwitz's avatar Neal Norwitz

Fix SF #749831, copy raises SystemError when getstate raises exception

parent f0b1a1fc
......@@ -515,6 +515,12 @@ class TestCopy(unittest.TestCase):
self.assert_(x is not y)
self.assert_(x[0] is not y[0])
def test_getstate_exc(self):
class EvilState(object):
def __getstate__(self):
raise ValueError, "ain't got no stickin' state"
self.assertRaises(ValueError, copy.copy, EvilState())
def test_main():
test_support.run_unittest(TestCopy)
......
......@@ -2536,6 +2536,8 @@ reduce_2(PyObject *obj)
if (getstate != NULL) {
state = PyObject_CallObject(getstate, NULL);
Py_DECREF(getstate);
if (state == NULL)
goto end;
}
else {
state = PyObject_GetAttrString(obj, "__dict__");
......
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