Skip to content
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

Merged

Conversation

reyoung
Copy link
Collaborator

@reyoung reyoung commented Sep 26, 2017

Fix #4451

class TestException(unittest.TestCase):
def test_exception(self):
self.assertRaises(core.EnforceNotMet,
lambda: core.__unittest_throw_exception__())
Copy link
Collaborator

@JiayiFeng JiayiFeng Sep 26, 2017

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

namespace paddle {
namespace pybind {

extern void BindException(pybind11::module& m);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this extern required?

Copy link
Collaborator Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok~

Copy link
Collaborator

@JiayiFeng JiayiFeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@reyoung reyoung merged commit d2edbe5 into PaddlePaddle:develop Sep 27, 2017
@reyoung reyoung deleted the feature/make_python_catch_enforce_not_met branch October 2, 2017 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants