-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Description
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Proposal:
I added a private _PyErr_WriteUnraisableMsg() API but it cannot be used in third party code, nor in stdlib extensions which try to avoid private/internal functions (like sqlite3). Moreover, _PyErr_WriteUnraisableMsg() API doesn't allow to fully customize the error message.
The limitation of _PyErr_WriteUnraisableMsg() affected PR #106674 which has to add ; consider using ... in the error message which is not great.
_PyErr_WriteUnraisableMsg(
"in PyMapping_HasKeyString(); consider using "
"PyMapping_GetOptionalItemString() or PyMapping_GetItemString()",
NULL);@serhiy-storchaka suggested to add an API which allows string formatting, similar to PyErr_Format().
_PyErr_WriteUnraisableMsg() was added in issue #81010.
By the way, we should go through all calls to PyErr_WriteUnraisable() and add more context to more these logs easier to get for developers: give more context about what the issue is, how to fix it, where it occurred, etc.
Linked PRs
- gh-108082: Add PyErr_FormatUnraisable() function #111086
- gh-108082: C API: Add tests for PyErr_WriteUnraisable() #111455
- [3.12] gh-108082: C API: Add tests for PyErr_WriteUnraisable() (GH-111455) #111507
- gh-108082: Use PyErr_FormatUnraisable() #111580
- gh-108082: Remove _PyErr_WriteUnraisableMsg() #111643