Skip to content

Commit 7e27da3

Browse files
committed
Export libc++ exceptions
1 parent 7e418f4 commit 7e27da3

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

include/pybind11/detail/common.h

+10-8
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,6 @@
164164
# endif
165165
#endif
166166

167-
#if !defined(PYBIND11_EXPORT_EXCEPTION)
168-
# if defined(__apple_build_version__)
169-
# define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
170-
# else
171-
# define PYBIND11_EXPORT_EXCEPTION
172-
# endif
173-
#endif
174-
175167
// For CUDA, GCC7, GCC8:
176168
// PYBIND11_NOINLINE_FORCED is incompatible with `-Wattributes -Werror`.
177169
// When defining PYBIND11_NOINLINE_FORCED, it is best to also use `-Wno-attributes`.
@@ -329,6 +321,16 @@ PYBIND11_WARNING_POP
329321
# endif
330322
#endif
331323

324+
// For libc++, the exceptions should be exported,
325+
// otherwise, the exception translation would be incorrect.
326+
#if !defined(PYBIND11_EXPORT_EXCEPTION)
327+
# if defined(__apple_build_version__) || (defined(_LIBCPP_VERSION) && !defined(__APPLE__))
328+
# define PYBIND11_EXPORT_EXCEPTION PYBIND11_EXPORT
329+
# else
330+
# define PYBIND11_EXPORT_EXCEPTION
331+
# endif
332+
#endif
333+
332334
// Must be after including <version> or one of the other headers specified by the standard
333335
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
334336
# define PYBIND11_HAS_U8STRING

tests/test_exceptions.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,8 @@ def test_cross_module_exceptions(msg):
7474
assert str(excinfo.value) == "'just local'"
7575

7676

77-
# TODO: FIXME
78-
@pytest.mark.xfail(
79-
"env.MACOS and (env.PYPY or pybind11_tests.compiler_info.startswith('Homebrew Clang')) or sys.platform.startswith('emscripten')",
80-
raises=RuntimeError,
81-
reason="See Issue #2847, PR #2999, PR #4324",
82-
)
8377
def test_cross_module_exception_translator():
84-
with pytest.raises(KeyError):
78+
with pytest.raises(RuntimeError):
8579
# translator registered in cross_module_tests
8680
m.throw_should_be_translated_to_key_error()
8781

0 commit comments

Comments
 (0)