-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make PyBind support C++ exception #4396
Make PyBind support C++ exception #4396
Conversation
class TestException(unittest.TestCase): | ||
def test_exception(self): | ||
self.assertRaises(core.EnforceNotMet, | ||
lambda: core.__unittest_throw_exception__()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could we get and check the error message? Use .message
?
It will be better to add another unit test of the error message here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
…ython_catch_enforce_not_met
namespace paddle { | ||
namespace pybind { | ||
|
||
extern void BindException(pybind11::module& m); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this extern
required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extern
is not necessary but useful for code reading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok~
…ython_catch_enforce_not_met
…ython_catch_enforce_not_met
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Fix #4451