Skip to content

Commit

Permalink
test for Python traceback in C++ exception what()
Browse files Browse the repository at this point in the history
  • Loading branch information
wlav committed Jan 5, 2023
1 parent 23e5d75 commit a25ca91
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ master: 2.4.2
* Walk the full inheritance tree to find the overloads
* Allow __destruct__ override in Python derived class
* Allow NULL function pointers to be returned as std::function objects
* Add Python traceback to C++ exception what()


2022-10-03: 2.4.1
Expand Down
17 changes: 17 additions & 0 deletions test/test_crossinheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,23 @@ def sum_value(self, val):
except ValueError as e:
assert errmsg in str(e)

cppyy.cppdef("""\
namespace CrossInheritance {
std::string call_base1(Base1* b) {
try {
b->sum_value(-7);
} catch (CPyCppyy::PyException& e) {
e.clear();
return e.what();
}
return "";
} }""")

res = cppyy.gbl.CrossInheritance.call_base1(d)

assert 'ValueError' in res
assert os.path.basename(__file__) in res

def test09_interface_checking(self):
"""Conversion errors should be Python exceptions"""

Expand Down

0 comments on commit a25ca91

Please sign in to comment.