From 3906d5c24411432977fed14ca5b6a0067118d938 Mon Sep 17 00:00:00 2001 From: Boris Staletic Date: Fri, 20 Nov 2020 11:40:04 +0100 Subject: [PATCH] Workaround for #2682 and #2422 by simply clearing the TypeError --- include/pybind11/cast.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 11c61a441fc..18f421700da 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -1870,7 +1870,12 @@ struct arg_v : arg { #if !defined(NDEBUG) , type(type_id()) #endif - { } + { + // Workaround! See https://github.com/pybind/pybind11/issues/2336 + if (PyErr_Occurred()) { + PyErr_Clear(); + } + } public: /// Direct construction with name, default, and description