diff --git a/modules/python/src2/cv2_util.hpp b/modules/python/src2/cv2_util.hpp index c15fcac486..a7deb5b575 100644 --- a/modules/python/src2/cv2_util.hpp +++ b/modules/python/src2/cv2_util.hpp @@ -71,7 +71,7 @@ public: } operator bool() { - return static_cast(obj_); + return obj_ != nullptr; } PyObject* release() diff --git a/modules/python/test/test_misc.py b/modules/python/test/test_misc.py index ed13d66b93..afe3fcc5db 100644 --- a/modules/python/test/test_misc.py +++ b/modules/python/test/test_misc.py @@ -223,9 +223,14 @@ class Arguments(NewOpenCVTests): for dtype in (object, str, np.complex128): test_array = np.zeros((4, 4, 3), dtype=dtype) msg = ".*type = {} is not supported".format(test_array.dtype) - self.assertRaisesRegex( - Exception, msg, cv.utils.dumpInputArray, test_array - ) + if sys.version_info[0] < 3: + self.assertRaisesRegexp( + Exception, msg, cv.utils.dumpInputArray, test_array + ) + else: + self.assertRaisesRegex( + Exception, msg, cv.utils.dumpInputArray, test_array + ) def test_20968(self): pixel = np.uint8([[[40, 50, 200]]])