Skip to content

object no longer passed to sys.unraisablehook #134732

Not planned
@graingert

Description

@graingert

Bug report

Bug description:

given

import gc
import sys

class Foo:
    def __del__(self):
        raise ValueError("__del__ is broken")


def main():
    v = None
    def unraisablehook(unraisable_arg):
        nonlocal v
        v = unraisable_arg

    sys.unraisablehook = unraisablehook
    Foo()
    gc.collect()
    print(v.object)


if __name__ == "__main__":
    sys.exit(main())

On Python 3.13 you get <function Foo.__del__ at 0x7181347936a0> on 3.14 you get None

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Activity

graingert

graingert commented on May 26, 2025

@graingert
ContributorAuthor

sometime between v3.14.0a4 and v3.14.0a5

graingert

graingert commented on May 26, 2025

@graingert
ContributorAuthor

bisected to a25042e

graingert

graingert commented on May 26, 2025

@graingert
ContributorAuthor

looks intentional:

The drawback is that it changes sys.unraisablehook arguments: the object is no longer set. In my PR, I had to update multiple tests to check err_msg (string) instead.

added
interpreter-core(Objects, Python, Grammar, and Parser dirs)
3.14bugs and security fixes
on May 26, 2025
graingert

graingert commented on May 26, 2025

@graingert
ContributorAuthor

closing this as not planed because it's an intentional change

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.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      object no longer passed to sys.unraisablehook · Issue #134732 · 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