gh-108082: Add PyErr_FormatUnraisable() function#111086
Conversation
vstinner
left a comment
There was a problem hiding this comment.
Variadic argument ... cannot be used in some programming languages like Go, see: capi-workgroup/problems#35 Would it be possible to add also a variant which takes an already formatted string?
Something like: PyErr_WriteUnraisableMsg(PyObject *msg) (I'm not sure about the name, nor the API).
Sorry, something went wrong.
vstinner
left a comment
There was a problem hiding this comment.
Would it be possible to not add this function to the limited C API in Python 3.13, but wait for Python 3.14?
Sorry, something went wrong.
What if change |
Sorry, something went wrong.
vstinner
left a comment
There was a problem hiding this comment.
Overall, the change LGTM. I just suggest to add a small example in the doc. I also propose to change how errors are handled, but that can be done later, and I can propose a followu-p PR for that if you want.
Sorry, something went wrong.
|
The main limitation of the new function is that it doesn't allow to pass an object. But I'm not sure that it's really useful. Maybe we should just deprecated this attribute of sys.unraisablehook. I don't know. I mostly added it to delegate the string formatting to the hook. |
Sorry, something went wrong.
Only 6 of about 70 use cases in CPython code actually pass an object. If it is needed, we can add yet one function, but the function which do not require to pass mandatory NULL argument in 90% of cases is more convenient. |
Sorry, something went wrong.
|
Thanks for the short example in the doc ;-) |
Sorry, something went wrong.
📚 Documentation preview 📚: https://cpython-previews--111086.org.readthedocs.build/