Properties on exception types #5572
Closed
davidcole1340
started this conversation in
Ideas
Replies: 1 comment
-
Actually this is a duplicate of #5275 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello! First of all, thanks for the great work on pybind11! It's made writing Python/C bindings very easy 💯
My module exposes a C++ exception using
py::register_exception()
. On the C++ side, this exception type contains an error code that I want to be accessible from Python-land.Is it currently possible to expose this error code to Python? I've had a look but seems this is not the case.
Checking the CPython docs, it seems the
PyErr_NewException
takes adict
argument that could be used to expose this property, but it seems pybind doesn't allow setting thisdict
argument when it creates an exception. Perhaps this could be used?Beta Was this translation helpful? Give feedback.
All reactions