]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport to 2.2.x:
authorGuido van Rossum <guido@python.org>
Mon, 3 Jun 2002 19:54:10 +0000 (19:54 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 3 Jun 2002 19:54:10 +0000 (19:54 +0000)
Address the residual issue with the fix for SF 551412 in
_PyType_Lookup().  Decided to clear the error condition in the
unfortunate but unlikely case that PyType_Ready() fails.

Objects/typeobject.c

index f5a1a01a49af6b6cd106c710d319e530b6611764..c2264541cec895e0baf5c386bcc156d1c7e49e12 100644 (file)
@@ -1219,8 +1219,18 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
        /* Look in tp_dict of types in MRO */
        mro = type->tp_mro;
        if (mro == NULL) {
-               if (PyType_Ready(type) < 0)
+               if (PyType_Ready(type) < 0) {
+                       /* It's not ideal to clear the error condition,
+                          but this function is documented as not setting
+                          an exception, and I don't want to change that.
+                          When PyType_Ready() can't proceed, it won't
+                          set the "ready" flag, so future attempts to ready
+                          the same type will call it again -- hopefully
+                          in a context that propagates the exception out.
+                       */
+                       PyErr_Clear();
                        return NULL;
+               }
                mro = type->tp_mro;
                assert(mro != NULL);
        }