From 3a027b82f0c6f7407de12b848cdd1db3e639b8c0 Mon Sep 17 00:00:00 2001 From: Eric Cousineau Date: Thu, 4 Mar 2021 22:42:48 -0500 Subject: [PATCH] drake: Workaround "Assertion '!PyErr_Occurred()'" for dtype=object --- include/pybind11/detail/class.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/pybind11/detail/class.h b/include/pybind11/detail/class.h index 2f414e5c7c..93dbe288c2 100644 --- a/include/pybind11/detail/class.h +++ b/include/pybind11/detail/class.h @@ -157,6 +157,12 @@ extern "C" inline int pybind11_meta_setattro(PyObject* obj, PyObject* name, PyOb * to do a special case bypass for PyInstanceMethod_Types. */ extern "C" inline PyObject *pybind11_meta_getattro(PyObject *obj, PyObject *name) { + // Workaround! See: + // https://github.com/RobotLocomotion/drake/issues/14740 + // https://github.com/pybind/pybind11/pull/2685 + if (PyErr_Occurred()) { + PyErr_Clear(); + } PyObject *descr = _PyType_Lookup((PyTypeObject *) obj, name); if (descr && PyInstanceMethod_Check(descr)) { Py_INCREF(descr);