Skip to content

Commit

Permalink
Export libc++ exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cyyever committed Sep 30, 2024
1 parent 7e418f4 commit 7e27da3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
18 changes: 10 additions & 8 deletions include/pybind11/detail/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,6 @@
# endif
#endif

#if !defined(PYBIND11_EXPORT_EXCEPTION)
# if defined(__apple_build_version__)
# define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
# else
# define PYBIND11_EXPORT_EXCEPTION
# endif
#endif

// For CUDA, GCC7, GCC8:
// PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`.
// When defining PYBIND11_NOINLINE_FORCED, it is best to also use `-Wno-attributes`.
Expand Down Expand Up @@ -329,6 +321,16 @@ PYBIND11_WARNING_POP
# endif
#endif

// For libc++, the exceptions should be exported,
// otherwise, the exception translation would be incorrect.
#if !defined(PYBIND11_EXPORT_EXCEPTION)
# if defined(__apple_build_version__) || (defined(_LIBCPP_VERSION) && !defined(__APPLE__))
# define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
# else
# define PYBIND11_EXPORT_EXCEPTION
# endif
#endif

// Must be after including <version> or one of the other headers specified by the standard
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
# define PYBIND11_HAS_U8STRING
Expand Down
8 changes: 1 addition & 7 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,8 @@ def test_cross_module_exceptions(msg):
assert str(excinfo.value) == "'just local'"


# TODO: FIXME
@pytest.mark.xfail(
"env.MACOS and (env.PYPY or pybind11_tests.compiler_info.startswith('Homebrew Clang')) or sys.platform.startswith('emscripten')",
raises=RuntimeError,
reason="See Issue #2847, PR #2999, PR #4324",
)
def test_cross_module_exception_translator():
with pytest.raises(KeyError):
with pytest.raises(RuntimeError):
# translator registered in cross_module_tests
m.throw_should_be_translated_to_key_error()

Expand Down

0 comments on commit 7e27da3

Please sign in to comment.