]> granicus.if.org Git - python/commitdiff
Christian Tismer:
authorGuido van Rossum <guido@python.org>
Sat, 25 Mar 2000 18:39:19 +0000 (18:39 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 25 Mar 2000 18:39:19 +0000 (18:39 +0000)
Added "better safe than sorry" patch to the new
trashcan code in object.c, to ensure that tstate
is not touched when it might be undefined.

Objects/object.c

index d2aa5428d4c29a60800bea653f391108ba586636..ab10e3e2677f3786502da4b64c75bfcb04c6f014 100644 (file)
@@ -920,6 +920,9 @@ Py_ReprLeave(obj)
 
   CT 2k0309
   modified to restore a possible error.
+
+  CT 2k0325
+  added better safe than sorry check for threadstate
 */
 
 int _PyTrash_delete_nesting = 0;
@@ -930,14 +933,17 @@ _PyTrash_deposit_object(op)
        PyObject *op;
 {
        PyObject *error_type, *error_value, *error_traceback;
-       PyErr_Fetch(&error_type, &error_value, &error_traceback);
+
+       if (PyThreadState_GET() != NULL)
+           PyErr_Fetch(&error_type, &error_value, &error_traceback);
 
        if (!_PyTrash_delete_later)
                _PyTrash_delete_later = PyList_New(0);
        if (_PyTrash_delete_later)
                PyList_Append(_PyTrash_delete_later, (PyObject *)op);
 
-       PyErr_Restore(error_type, error_value, error_traceback);
+       if (PyThreadState_GET() != NULL)
+           PyErr_Restore(error_type, error_value, error_traceback);
 }
 
 void