gh-105373: Remove the PyObject_SetAttr(NULL) deprecation by vstinner · Pull Request #105374 · python/cpython
Remove the deprecation on the following functions: * PyObject_SetAttr(obj, attr_name, NULL) * PyObject_SetAttrString(obj, attr_name, NULL) * PySequence_SetItem(obj, i, NULL) * PySequence_SetSlice(obj, i1, i2, NULL) Deprecation added by commit ed82604.
Deprecation added by issue #69887. cc @serhiy-storchaka @vadmium
I would prefer that either we fully removed these deprecations, or to really deprecate them: emit DeprecationWarning at runtime.
What is changed since it was discussed 8 years ago?
I would like to clarify what is really deprecated or not in Python 3.13. I don't see the value of a mention of a deprecation in the documentation without using .. deprecated:: markup and without emitting a DeprecationWarning at runtime.
IMO passing NULL is just fine, it's not going to change, so there is no need to deprecate it.
In 2015, you wrote:
I think the conclusion of Python_Dev discussion is that it is not worth to deprecate this behavior in the code.
So well, I propose to actually not deprecate it :-D
It is a bug magnet. It is easy to get the NULL pointer instead of a pointer to object (just forgot to check for error) and delete instead of set.
Oh right. I would prefer to emit a DeprecationWarning in this case and prepare a migration plan towards "Del" functions instead. I don't think that a sentence in the documentation is enough to help users to avoid mistakes.
CAM-Gerlach
changed the title
gh-105373: PyObject_SetAttr(NULL) is no longer deprecated
gh-105373: Remove the PyObject_SetAttr(NULL) deprecation
I close this PR in favor of issue #106572: Deprecate PyObject_SetAttr(obj, name, NULL): PyObject_DelAttr(obj, name) must be used instead.
vstinner
deleted the
keep_obj_setattr_null
branch