Skip to content

weakref.finalize documentation refers to old interpreter shutdown behavior #69524

Not planned

Description

@MojoVampire
BPO 25337
Nosy @pitrou, @MojoVampire, @csabella

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 2015-10-08.02:20:40.088>
labels = ['3.7', '3.8', 'docs']
title = 'weakref.finalize documentation refers to old interpreter shutdown behavior'
updated_at = <Date 2019-02-25.23:42:27.946>
user = 'https://github.com/MojoVampire'

bugs.python.org fields:

activity = <Date 2019-02-25.23:42:27.946>
actor = 'cheryl.sabella'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2015-10-08.02:20:40.088>
creator = 'josh.r'
dependencies = []
files = []
hgrepos = []
issue_num = 25337
keywords = []
message_count = 2.0
messages = ['252504', '336580']
nosy_count = 4.0
nosy_names = ['pitrou', 'docs@python', 'josh.r', 'cheryl.sabella']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue25337'
versions = ['Python 3.7', 'Python 3.8']

Activity

  1. MojoVampire commented on Oct 8, 2015

    MojoVampiremannequin
    MannequinAuthor

    In weakref.finalize's documentation ( https://docs.python.org/3/library/weakref.html#weakref.finalize ), it says:

    "A finalizer will never invoke its callback during the later part of the interpreter shutdown when module globals are liable to have been replaced by None."

    While it may not invoke its callback during shutdown (I don't know if it does, or if it should), as of Python 3.4 (which is when weakref.finalize was introduced), module globals aren't set to None anymore, right? https://docs.python.org/3/whatsnew/3.4.html#whatsnew-pep-442

    Presumably the docs should be updated not to mention a behavior that no longer occurs (and if it will or should be invoked, weakref.finalizer should have documentation or code updated).

  2. added
    docs
    on Oct 8, 2015
  3. csabella commented on Feb 25, 2019

    @csabella
    Contributor

    Adding @pitrou to the nosylist as he implemented PEP-442 in bpo-18112. If he agrees with the proposed change, then I believe this can be marked as 'easy'.

  4. added
    3.7 (EOL)
    3.8 (EOL)
    on Feb 25, 2019
  5. transferred this issue fromon Apr 10, 2022
  6. serhiy-storchaka commented on Nov 27, 2026

    @serhiy-storchaka
    Member

    This statement is still correct. weakref.finalize callbacks are called from an atexit hook and are not called after it. Later in the shutdown, the globals of modules that are still alive can still be replaced by None. The outdated statement in the "Comparing finalizers with __del__() methods" section is fixed in #162769 (gh-64352).

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.7 (EOL)3.8 (EOL)docs

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions