Skip to content

PyObject_SetAttr doesn't mention value = NULL #66238

Closed

Description

@pitrou
BPO 22039
Nosy @pitrou, @encukou, @vadmium, @serhiy-storchaka, @miss-islington, @iritkatriel
PRs
  • bpo-22039: [doc] clarify that there are no plans to disable deleting … #30639
  • [3.10] bpo-22039: [doc] clarify that there are no plans to disable deleting an attribute via PyObject_SetAttr (GH-30639) #30684
  • [3.9] bpo-22039: [doc] clarify that there are no plans to disable deleting an attribute via PyObject_SetAttr (GH-30639) #30685
  • Superseder
  • bpo-25701: Document that tp_setattro and tp_setattr are used for deleting attributes
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2022-01-19.12:07:27.068>
    created_at = <Date 2014-07-22.17:56:30.583>
    labels = ['3.11', 'type-bug', '3.9', '3.10', 'docs']
    title = "PyObject_SetAttr doesn't mention value = NULL"
    updated_at = <Date 2022-01-19.12:34:36.338>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2022-01-19.12:34:36.338>
    actor = 'iritkatriel'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2022-01-19.12:07:27.068>
    closer = 'iritkatriel'
    components = ['Documentation']
    creation = <Date 2014-07-22.17:56:30.583>
    creator = 'pitrou'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 22039
    keywords = ['patch']
    message_count = 9.0
    messages = ['223678', '255704', '282074', '398808', '410755', '410788', '410937', '410938', '410939']
    nosy_count = 7.0
    nosy_names = ['pitrou', 'petr.viktorin', 'docs@python', 'martin.panter', 'serhiy.storchaka', 'miss-islington', 'iritkatriel']
    pr_nums = ['30639', '30684', '30685']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = '25701'
    type = 'behavior'
    url = 'https://bugs.python.org/issue22039'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. pitrou commented on Jul 22, 2014

      @pitrou
      MemberAuthor

      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.

    2. added
      docsDocumentation in the Doc dir
      type-bugAn unexpected behavior, bug, or error
      on Jul 22, 2014
    3. serhiy-storchaka commented on Dec 2, 2015

      @serhiy-storchaka
      Member

      See two alternative issues: bpo-25701 for documenting existing behavior, and bpo-25773 for deprecating it (and converting PyObject_DelAttr to a function).

    4. vadmium commented on Nov 30, 2016

      @vadmium
      Member

      As of bpo-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?

    5. iritkatriel commented on Aug 2, 2021

      @iritkatriel
      Member

      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

    6. iritkatriel commented on Jan 17, 2022

      @iritkatriel
      Member

      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’?

    7. encukou commented on Jan 17, 2022

      @encukou
      Member

      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."

    8. iritkatriel commented on Jan 19, 2022

      @iritkatriel
      Member

      New changeset 3bf6315 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)
      3bf6315

    9. miss-islington commented on Jan 19, 2022

      @miss-islington
      Contributor

      New changeset 7b694b8 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)
      7b694b8

    10. iritkatriel commented on Jan 19, 2022

      @iritkatriel
      Member

      New changeset 0861a50 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)
      0861a50

    11. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifedocsDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions