mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Add support for nested C++11 exceptions (#3608)
* Add support for nested C++11 exceptions * Remove wrong include * Fix if directive * Fix missing skipif * Simplify code and try to work around MSVC bug * Clarify comment * Further simplify code * Remove the last extra throw statement * Qualify auto * Fix typo * Add missing return for consistency * Fix clang-tidy complaint * Fix python2 stub * Make clang-tidy happy * Fix compile error * Fix python2 function signature * Extract C++20 utility and backport * Cleanup code a bit more * Improve test case * Consolidate code and fix signature * Fix typo
This commit is contained in:
@@ -239,6 +239,14 @@ def test_nested_throws(capture):
|
||||
assert str(excinfo.value) == "this is a helper-defined translated exception"
|
||||
|
||||
|
||||
@pytest.mark.skipif("env.PY2")
|
||||
def test_throw_nested_exception():
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
m.throw_nested_exception()
|
||||
assert str(excinfo.value) == "Outer Exception"
|
||||
assert str(excinfo.value.__cause__) == "Inner Exception"
|
||||
|
||||
|
||||
# This can often happen if you wrap a pybind11 class in a Python wrapper
|
||||
def test_invalid_repr():
|
||||
class MyRepr(object):
|
||||
|
||||
Reference in New Issue
Block a user