diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index d37ad48bf..3695998f6 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -699,7 +699,7 @@ namespace swig { *seq = pseq; return SWIG_NEWOBJ; } else { - return pyseq.check(); + return pyseq.check() ? SWIG_OK : SWIG_ERROR; } } catch (std::exception& e) { if (seq) { diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg index fc181c69c..fa8d047fd 100644 --- a/Lib/python/pystdcommon.swg +++ b/Lib/python/pystdcommon.swg @@ -162,22 +162,22 @@ namespace swig { template struct traits_check { - static int check(PyObject *obj) { - int res = asval(obj, (Type *)(0)); - return obj && SWIG_IsOK(res) ? res : 0; + static bool check(PyObject *obj) { + int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR; + return SWIG_IsOK(res) ? true : false; } }; template struct traits_check { - static int check(PyObject *obj) { - int res = asptr(obj, (Type **)(0)); - return obj && SWIG_IsOK(res) ? res : 0; + static bool check(PyObject *obj) { + int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR; + return SWIG_IsOK(res) ? true : false; } }; template - inline int check(PyObject *obj) { + inline bool check(PyObject *obj) { return traits_check::category>::check(obj); } }