Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.14] change in behaviour in gc.get_referrers(some_local) #125603

Open
graingert opened this issue Oct 16, 2024 · 1 comment
Open

[3.14] change in behaviour in gc.get_referrers(some_local) #125603

graingert opened this issue Oct 16, 2024 · 1 comment
Assignees
Labels
3.14 new features, bugs and security fixes triaged The issue has been accepted as valid by a triager. type-bug An unexpected behavior, bug, or error

Comments

@graingert
Copy link
Contributor

graingert commented Oct 16, 2024

Bug report

Bug description:

import gc

async def demo():
    class A:
        pass

    a = A()
    print(gc.get_referrers(a))


try:
    demo().send(None)
except StopIteration as e:
    print(f"{e.value=}")

on 3.11-3.13 this prints:

[]
e.value=None

on 3.14 this prints:

[<coroutine object demo at 0x7d00fff85000>]
e.value=None

this makes gc.get_referrers less useful in detecting cyclic garbage where I'd like to be able to make the assertion that the current frame is the only referrer to an Exception.

the alternative is to hold a weak reference to the object, delete the object and see if the weak reference is dead with the gc disabled. But then I don't get any debug information in my failing test of why the object is still alive.

CPython versions tested on:

3.14, CPython main branch

Operating systems tested on:

Linux

note: @markshannon asked me to open this issue

Linked PRs

@graingert graingert added type-bug An unexpected behavior, bug, or error 3.14 new features, bugs and security fixes labels Oct 16, 2024
@graingert graingert added the triaged The issue has been accepted as valid by a triager. label Oct 16, 2024
@graingert
Copy link
Contributor Author

graingert commented Oct 16, 2024

The behavior change was caused by this PR #124392

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 new features, bugs and security fixes triaged The issue has been accepted as valid by a triager. type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants