This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyObject_SetAttr doesn't mention value = NULL
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder: Document that tp_setattro and tp_setattr are used for deleting attributes
View: 25701
Assigned To: docs@python Nosy List: docs@python, iritkatriel, martin.panter, miss-islington, petr.viktorin, pitrou, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2014-07-22 17:56 by pitrou, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30639 merged iritkatriel, 2022-01-17 14:53
PR 30684 merged miss-islington, 2022-01-19 12:04
PR 30685 merged miss-islington, 2022-01-19 12:04
Messages (9)
msg223678 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-07-22 17:56
PyObject_SetAttr, when called with value == NULL, actually deletes the attribute, but the documentation doesn't say it. It mentions PyObject_DelAttr, but it is only a macro and can therefore not be looked up using e.g. ctypes.
msg255704 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-12-02 10:53
See two alternative issues: issue25701 for documenting existing behavior, and issue25773 for deprecating it (and converting PyObject_DelAttr to a function).
msg282074 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-11-30 10:55
As of Issue 25701, the null-to-delete feature is documented as being deprecated in favour of calling the related Del functions or macros. There was a python-dev thread at <https://marc.info/?i=n32kch$eie$1@ger.gmane.org>.

I’m not sure if that is good enough, or do we need to e.g. clarify that the deprecation is only at the API (C header) level, and not the ABI level?
msg398808 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-08-02 22:55
This behaviour is documented as deprecated all the way back to 2.7. Should we repurpose the issue to removing it? Otherwise it can be closed.

https://docs.python.org/2.7/c-api/object.html#c.PyObject_SetAttr
msg410755 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-17 10:39
I read the python-dev thread now and I see it was decided that it’s not worth removing it.

In recent versions of the doc it is mentioned that the function is in the stable ABI. Should we clarify exactly what is meant by ‘deprecated’?
msg410788 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2022-01-17 14:16
This cannot be changed in 3.x, since the PyObject_DelAttr macro calls PyObject_SetAttr(..., NULL), and the macro is expanded in all extensions that use the stable ABI.
(Technically, it would be possible to add a PyObject_SetAttr *macro* that would warn/fail, while keeping the PyObject_SetAttr *function* untouched, but that would be a pain to test/maintain.) 

The wording could be clarified to something like: "This behaviour is deprecated in favour of using PyObject_DelAttr(), but there are currently no plans to remove it."
msg410937 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-19 12:03
New changeset 3bf6315c4cabf72d64e65e6f85bf72c65137255a by Irit Katriel in branch 'main':
bpo-22039: [doc] clarify that there are no plans to disable deleting an attribute via PyObject_SetAttr (GH-30639)
https://github.com/python/cpython/commit/3bf6315c4cabf72d64e65e6f85bf72c65137255a
msg410938 - (view) Author: miss-islington (miss-islington) Date: 2022-01-19 12:30
New changeset 7b694b816f30c463ffcab0952d3319320d23e154 by Miss Islington (bot) in branch '3.9':
[3.9] bpo-22039: [doc] clarify that there are no plans to disable deleting an attribute via PyObject_SetAttr (GH-30639) (GH-30685)
https://github.com/python/cpython/commit/7b694b816f30c463ffcab0952d3319320d23e154
msg410939 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-19 12:34
New changeset 0861a50bd434d1f3e12fe7122e37356f1fce93dc by Miss Islington (bot) in branch '3.10':
bpo-22039: [doc] clarify that there are no plans to disable deleting an attribute via PyObject_SetAttr (GH-30639) (GH-30684)
https://github.com/python/cpython/commit/0861a50bd434d1f3e12fe7122e37356f1fce93dc
History
Date User Action Args
2022-04-11 14:58:06adminsetgithub: 66238
2022-01-19 12:34:36iritkatrielsetmessages: + msg410939
2022-01-19 12:30:09miss-islingtonsetmessages: + msg410938
2022-01-19 12:07:27iritkatrielsetstatus: open -> closed
resolution: duplicate -> fixed
stage: patch review -> resolved
2022-01-19 12:04:06miss-islingtonsetpull_requests: + pull_request28884
2022-01-19 12:04:01miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request28883
2022-01-19 12:03:59iritkatrielsetmessages: + msg410937
2022-01-17 15:08:58iritkatrielsetversions: + Python 3.9, Python 3.10, Python 3.11, - Python 2.7, Python 3.4, Python 3.5
2022-01-17 14:53:27iritkatrielsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28842
2022-01-17 14:16:19petr.viktorinsetmessages: + msg410788
2022-01-17 13:58:21iritkatrielsetnosy: + petr.viktorin
2022-01-17 10:39:54iritkatrielsetstatus: pending -> open

messages: + msg410755
2021-08-02 22:55:13iritkatrielsetstatus: open -> pending

nosy: + iritkatriel
messages: + msg398808

superseder: Document that tp_setattro and tp_setattr are used for deleting attributes
resolution: duplicate
2016-11-30 10:55:40martin.pantersetmessages: + msg282074
2016-11-29 19:34:51serhiy.storchakasetnosy: + martin.panter
2015-12-02 10:53:25serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg255704
2014-07-22 17:56:30pitroucreate