[issue34068] traceback.clear_frames(): Objects/typeobject.c:3086: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed.

STINNER Victor report at bugs.python.org
Tue Jul 17 07:25:25 EDT 2018


STINNER Victor <vstinner at redhat.com> added the comment:

> The assertion failure is a little bit "far" from the bug: would it make sense to add "assert(!PyErr_Occurred());" to the entry point of:

Stefan, Serhiy: any opinion on my idea?

For example, PyObject_HasAttr() can replace and clear the current exception *by design*. This function does more or less:

try: obj.attr; return True
except AttributeError: return False

int
PyObject_HasAttr(PyObject *v, PyObject *name)
{
    PyObject *res;
    if (_PyObject_LookupAttr(v, name, &res) < 0) {
        PyErr_Clear();
        return 0;
    }
    if (res == NULL) {
        return 0;
    }
    Py_DECREF(res);
    return 1;
}

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34068>
_______________________________________


More information about the Python-bugs-list mailing list