introspect types built by create_exception!#6209
Conversation
4b4b0a4 to
0b7d5ff
Compare
|
Thank you for this! Sadly @davidhewitt (the main pyo3 maintainer) is not very keen to add more complexity in the |
|
Thanks for the reply and pointer! I wasnt aware of it and I saw an unticked checkbox on the tracking issue, so i figured it would be nice to support it. Is there a rough design in how to make pyclasses support exceptions, or any way I can help out with implementing that? |
|
I think API wise I think we'd prefer There is #295 which is a pretty old issue though. There is also #4186 (see #4186 (comment) as well) Both of those PRs ran into some issues related to subclassing on abi3 builds, but we have evolved the subclassing machinery since and have also dropped support for older python versions. |
|
Bit of a brainfart obviously; |
|
It's also possible since #5733 to do this on abi3 (for 3.12+). One point that is still missing to make this more usable is adding the ability to pass down arguments to the native superclass during construction, so that an error message can be set for example (I plan to have a look at that again). Otherwise I think the parts are there, |
Does that mean it is currently not supported for python 3.10? |
|
Yes, when using abi3 |
Looks like piping the data to a doc(hidden) procedural macro is good enough and didn't require much implementation effort.
see
pytests/stubs/exception.pyifor how this changed stub generation.newsfragments: pending.
tested locally using
nox -s test