]> granicus.if.org Git - python/commitdiff
Fix SF #749831, copy raises SystemError when getstate raises exception
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 8 Jun 2003 13:19:58 +0000 (13:19 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 8 Jun 2003 13:19:58 +0000 (13:19 +0000)
Lib/test/test_copy.py
Objects/typeobject.c

index 0e39e8356de15ab597a5985c37adfe7200540b3c..c734a9a9d408390f364fca9d66724d73a54fdf30 100644 (file)
@@ -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)
 
index 93f34ed1f9c15f68f0e69ee719394085f6a9126f..3e1569763fd28f205cc3637165f6a452eb2ebf74 100644 (file)
@@ -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__");