diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 4788ef1b5e..bfd23b7e78 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -1274,14 +1274,16 @@ PyObject* pyopencv_from(const Moments& m) template PyObject* pyopencv_from(const cv::Ptr& p) { - if (!p) return Py_None; + if (!p) + Py_RETURN_NONE; return pyopencv_from(*p); } template bool pyopencv_to(PyObject *o, Ptr& p, const char *name) { - if (!o || o == Py_None) return true; + if (!o || o == Py_None) + return true; p = makePtr(); return pyopencv_to(o, *p, name); }