Merge pull request #19440 from paroj:pyexcept
This commit is contained in:
commit
863ecded30
@ -8,6 +8,8 @@
|
|||||||
#include <opencv2/core/async.hpp>
|
#include <opencv2/core/async.hpp>
|
||||||
#include <opencv2/core/detail/async_promise.hpp>
|
#include <opencv2/core/detail/async_promise.hpp>
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace cv { namespace utils {
|
namespace cv { namespace utils {
|
||||||
//! @addtogroup core_utils
|
//! @addtogroup core_utils
|
||||||
//! @{
|
//! @{
|
||||||
@ -113,6 +115,12 @@ String dumpRange(const Range& argument)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CV_WRAP static inline
|
||||||
|
void testRaiseGeneralException()
|
||||||
|
{
|
||||||
|
throw std::runtime_error("exception text");
|
||||||
|
}
|
||||||
|
|
||||||
CV_WRAP static inline
|
CV_WRAP static inline
|
||||||
AsyncArray testAsyncArray(InputArray argument)
|
AsyncArray testAsyncArray(InputArray argument)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -206,6 +206,11 @@ catch (const cv::Exception &e) \
|
|||||||
{ \
|
{ \
|
||||||
pyRaiseCVException(e); \
|
pyRaiseCVException(e); \
|
||||||
return 0; \
|
return 0; \
|
||||||
|
} \
|
||||||
|
catch (const std::exception &e) \
|
||||||
|
{ \
|
||||||
|
PyErr_SetString(opencv_error, e.what()); \
|
||||||
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|||||||
@ -47,6 +47,12 @@ class Bindings(NewOpenCVTests):
|
|||||||
boost.getMaxDepth() # from ml::DTrees
|
boost.getMaxDepth() # from ml::DTrees
|
||||||
boost.isClassifier() # from ml::StatModel
|
boost.isClassifier() # from ml::StatModel
|
||||||
|
|
||||||
|
def test_raiseGeneralException(self):
|
||||||
|
with self.assertRaises((cv.error,),
|
||||||
|
msg='C++ exception is not propagated to Python in the right way') as cm:
|
||||||
|
cv.utils.testRaiseGeneralException()
|
||||||
|
self.assertEqual(str(cm.exception), 'exception text')
|
||||||
|
|
||||||
def test_redirectError(self):
|
def test_redirectError(self):
|
||||||
try:
|
try:
|
||||||
cv.imshow("", None) # This causes an assert
|
cv.imshow("", None) # This causes an assert
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user