Skip to content

tp_dealloc docs should mention error indicator may be set #89373

Closed
@ezyang

Description

@ezyang
mannequin
BPO 45210
Nosy @vstinner, @ezyang
PRs
  • gh-89373: Document that error indicator may be set in tp_dealloc #28358
  • gh-89373: _Py_Dealloc() checks tp_dealloc exception #32357
  • Files
  • unicode_dealloc_bug.patch
  • 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 = None
    created_at = <Date 2021-09-15.16:47:23.387>
    labels = ['3.11', 'type-feature', 'docs']
    title = 'tp_dealloc docs should mention error indicator may be set'
    updated_at = <Date 2022-04-06.09:40:23.648>
    user = 'https://github.com/ezyang'

    bugs.python.org fields:

    activity = <Date 2022-04-06.09:40:23.648>
    actor = 'vstinner'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation']
    creation = <Date 2021-09-15.16:47:23.387>
    creator = 'ezyang'
    dependencies = []
    files = ['50724']
    hgrepos = []
    issue_num = 45210
    keywords = ['patch']
    message_count = 3.0
    messages = ['401854', '401944', '416849']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'docs@python', 'python-dev', 'ezyang']
    pr_nums = ['28358', '32357']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue45210'
    versions = ['Python 3.11']

    Activity

    ezyang

    ezyang commented on Sep 15, 2021

    @ezyang
    MannequinAuthor
    No description provided.
    added
    docsDocumentation in the Doc dir
    type-featureA feature request or enhancement
    on Sep 15, 2021
    vstinner

    vstinner commented on Sep 16, 2021

    @vstinner
    Member

    I'm not sure that it's a feature. Maybe we should modify to never call tp_dealloc with an exception set.

    vstinner

    vstinner commented on Apr 6, 2022

    @vstinner
    Member

    I wrote #32357 to check in debug mode that tp_dealloc functions leave the current exception unchanged. You can use attached unicode_dealloc_bug.patch to inject a bug to test my PR. Example ("make" is enough to trigger the bug):
    ---
    Fatal Python error: _Py_Dealloc: Deallocator of type 'str' cleared the current exception
    Python runtime state: initialized

    Current thread 0x00007ff28d45a740 (most recent call first):
    File "/home/vstinner/python/main/Lib/sysconfig.py", line 349 in _parse_makefile
    File "/home/vstinner/python/main/Lib/sysconfig.py", line 470 in _generate_posix_vars
    File "/home/vstinner/python/main/Lib/sysconfig.py", line 845 in _main
    File "/home/vstinner/python/main/Lib/sysconfig.py", line 857 in <module>
    File "<frozen runpy>", line 88 in _run_code
    File "<frozen runpy>", line 198 in _run_module_as_main
    generate-posix-vars failed
    ---

    transferred this issue fromon Apr 10, 2022
    added a commit that references this issue on Apr 21, 2022

    gh-89373: _Py_Dealloc() checks tp_dealloc exception (#32357)

    364ed94
    vstinner

    vstinner commented on Apr 27, 2022

    @vstinner
    Member

    I merged #32357: commit 364ed94

    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.11only security fixesdocsDocumentation in the Doc dirtype-featureA feature request or enhancement

      Projects

      No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        tp_dealloc docs should mention error indicator may be set · Issue #89373 · python/cpython

        Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

        Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant