It is a new name of former _PyObject_LookupAttr() added in #76752.
int PyObject_GetOptionalAttr(PyObject *obj, PyObject *attr_name, PyObject **result);
Discussion about making it public and naming: https://discuss.python.org/t/make-pyobject-lookupattr-public/29104.
See also other new functions with similar interface in #106307 and #106004.
pythongh-106521: Add PyObject_GetOptionalAttr() function
gh-106521: Add PyObject_GetOptionalAttr() function (GH-106522)
pythongh-106521: Replace _PyObject_LookupAttr with PyObject_GetOption…
gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)
I added PyObject_GetOptionalAttr() and PyObject_GetOptionalAttrString() to pythoncapi-compat: python/pythoncapi-compat@157d6d4
PRs are merged, this looks done.
Activity
pythongh-106521: Add PyObject_GetOptionalAttr() function
gh-106521: Add PyObject_GetOptionalAttr() function (GH-106522)
pythongh-106521: Replace _PyObject_LookupAttr with PyObject_GetOption…
gh-106521: Remove _PyObject_LookupAttr() function (GH-106642)
vstinner commented on Jul 12, 2023
I added PyObject_GetOptionalAttr() and PyObject_GetOptionalAttrString() to pythoncapi-compat: python/pythoncapi-compat@157d6d4
carljm commented on Jul 13, 2023
PRs are merged, this looks done.