-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
C API: Add replacements for PyObject_HasAttr() etc #108511
Comments
Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
In the PR you propose new names of the form |
There is a single precedence: the I asked about names in https://discuss.python.org/t/replacements-for-pymapping-haskey-pymapping-haskeystring-pyobject-hasattr-and-pyobject-hasattrstring/32589, and We can also use Other approach was used for the |
Okay, I think just introducing the new names now seems the right thing, and it looks like |
I didn't like when I didn't like when it was removed: is it ok to remove if you keep Python 3.6 support? Is it going to break stuffs? IMO this dark macro magic is hard to understand as an user. |
…H-109025) Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
…ors (pythonGH-109025) Add the following functions: * PyObject_HasAttrWithError() * PyObject_HasAttrStringWithError() * PyMapping_HasKeyWithError() * PyMapping_HasKeyStringWithError()
Feature or enhancement
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
#75753
#106672
Proposal:
Functions
PyDict_GetItem()
,PyDict_GetItemString()
,PyMapping_HasKey()
,PyMapping_HasKeyString()
,PyObject_HasAttr()
,PyObject_HasAttrString()
andPySys_GetObject()
have a flaw -- they clear any error raised inside the function, including important and critical errors. They cannot be fixed, because the user code which use them do not handle errors. There are replacements free from this flaw forPyDict_GetItem()
(PyDict_GetItemWithError()
andPyDict_GetItemRef()
) and, in some applications, toPyDict_GetItemString()
(PyDict_GetItemRefString()
).We need new functions similar to
PyMapping_HasKey()
,PyMapping_HasKeyString()
,PyObject_HasAttr()
,PyObject_HasAttrString()
which return three-state value (1
- yes,0
-- no, and-1
--error). What should be their names? Add theWithError
suffix? Add theEx
sufix? Add the2
suffix?Linked PRs
The text was updated successfully, but these errors were encountered: