[C API] Deprecate calling PyObject_SetAttr(obj, attr, NULL) with an exception set #135075
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
topic-C-API
type-feature
A feature request or enhancement
Uh oh!
There was an error while loading. Please reload this page.
The issue gh-106572 changed
PyObject_DelAttr()
andPyObject_DelAttrString()
implementation from a macro to a function (commit 1f2921b).Now I propose deprecating calls
PyObject_SetAttr(obj, attr, NULL)
andPyObject_SetAttrString(obj, attr, NULL)
with an exception set to help detecting bugs. When the code creating the attribute value failed, it should be handled before callingPyObject_SetAttr[String)()
to avoid deleting the attribute by mistake.The change affects also the stable ABI.
I also propose to treat this deprecation as an error in Python 3.17.
Example of buggy code:
Correct code:
Linked PRs
The text was updated successfully, but these errors were encountered: