diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 11c61a441f..c428e3f13a 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -1870,7 +1870,14 @@ struct arg_v : arg { #if !defined(NDEBUG) , type(type_id()) #endif - { } + { + // Workaround! See: + // https://github.com/pybind/pybind11/issues/2336 + // https://github.com/pybind/pybind11/pull/2685#issuecomment-731286700 + if (PyErr_Occurred()) { + PyErr_Clear(); + } + } public: /// Direct construction with name, default, and description