fix: throwing repr caused a segfault (#2389)
* fix: throwing repr caused a segfault
* fixup! ci: include Python 3.9 RC1 (#2387)
diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py
index 83a46bf..7d7088d 100644
--- a/tests/test_exceptions.py
+++ b/tests/test_exceptions.py
@@ -178,3 +178,14 @@
with pytest.raises(m.MyException5) as excinfo:
m.try_catch(m.MyException, pycatch, m.MyException, m.throws5)
assert str(excinfo.value) == "this is a helper-defined translated exception"
+
+
+# This can often happen if you wrap a pybind11 class in a Python wrapper
+def test_invalid_repr():
+
+ class MyRepr(object):
+ def __repr__(self):
+ raise AttributeError("Example error")
+
+ with pytest.raises(TypeError):
+ m.simple_bool_passthrough(MyRepr())