-
Notifications
You must be signed in to change notification settings - Fork 1
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
Functions must not suppress exceptions #35
Comments
I think that's a bit strong. There are certain situations where a certain type of failure is commonly expected by the user, and then in some cases we have the option to design a more ergonomic API (e.g. |
We haven't really designed the separation between "API for people who want stability" vs "API for people who want speed", but I'd say that an API that signals failure without an exception belongs in the latter category, and should be a special case of one that exists in the former. Otherwise, how will someone who wants a normal looking AttributeError create it? Do they have to copy-paste the message themselves? (What would be nice is to be able to distinguish "this operation failed with |
I softened the wording. Doing this avoids creating an exception object; that is reason enough to design (some of) the API that way.
I wonder if we need to restore some of the old way of handling excetpions, where “type” and “value” (and traceback) were decoupled until something needed a materialized exception object. Raising an exception that's immediately handled was much cheaper in that scheme. Or maybe add functions like
That's another point for the |
That would be fine by me, I always appreciated the low cost of that scheme. But I believe it interacts poorly with some of the interpreter optimisations? |
In capi-workgroup/problems#51 (comment) list, the remaining function is PySys_GetObject(): thre is no variant which does not suppress exceptions. |
From capi-workgroup/problems#51
Functions must not suppress unknown exceptions, except ones that specifically to do just that (like
PyErr_Clear
).(#13 is related: If a function has a common “failure”, like “attribute not found” from a getattr, that can be treated as success instead, and be signaled with a dedicated return value. This avoids creating an exception object.)
The text was updated successfully, but these errors were encountered: