This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients ZackerySpytz, miss-islington, nedbat, scoder, serhiy.storchaka, vstinner
Date 2018-07-17.11:25:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531826725.02.0.56676864532.issue34068@psf.upfronthosting.co.za>
In-reply-to
Content
> 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;
}
History
Date User Action Args
2018-07-17 11:25:25vstinnersetrecipients: + vstinner, scoder, nedbat, serhiy.storchaka, ZackerySpytz, miss-islington
2018-07-17 11:25:25vstinnersetmessageid: <1531826725.02.0.56676864532.issue34068@psf.upfronthosting.co.za>
2018-07-17 11:25:25vstinnerlinkissue34068 messages
2018-07-17 11:25:24vstinnercreate