Skip to content

C API: Report ignored exception in C API functions which ignore all errors #106672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
serhiy-storchaka opened this issue Jul 12, 2023 · 0 comments
Labels
topic-C-API type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Jul 12, 2023

Some C API functions, like PyDict_GetItem() and PyObject_HasAttr() (see capi-workgroup/problems#51 for full list), clears all errors which occurred during execution of these functions. The user has no way to distinguish the normal negative result from error.

There is no way to fix such C API. But at least we can make ignoring errors less unnoticeable. The proposed PR adds _PyErr_WriteUnraisableMsg() when an unrelated error is ignored. It is the same way as reporting errors during object destruction.

Linked PRs

@serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement topic-C-API labels Jul 12, 2023
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jul 12, 2023
Functions which indiscriminately ignore all errors now report them as
unraisable errors.
serhiy-storchaka added a commit that referenced this issue Nov 7, 2023
Functions which indiscriminately ignore all errors now report them as
unraisable errors.
hugovk pushed a commit to hugovk/cpython that referenced this issue Nov 8, 2023
…nGH-106674)

Functions which indiscriminately ignore all errors now report them as
unraisable errors.
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
…nGH-106674)

Functions which indiscriminately ignore all errors now report them as
unraisable errors.
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
…nGH-106674)

Functions which indiscriminately ignore all errors now report them as
unraisable errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-C-API type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants
@serhiy-storchaka and others