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

gc.get_referrers behavior change 3.6 to 3.7 #78789

Closed
bryevdv mannequin opened this issue Sep 7, 2018 · 3 comments
Closed

gc.get_referrers behavior change 3.6 to 3.7 #78789

bryevdv mannequin opened this issue Sep 7, 2018 · 3 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir

Comments

@bryevdv
Copy link
Mannequin

bryevdv mannequin commented Sep 7, 2018

BPO 34608
Nosy @pitrou, @benjaminp, @methane, @bryevdv

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 2018-09-09.13:54:32.678>
created_at = <Date 2018-09-07.16:30:04.024>
labels = ['3.7', 'library']
title = 'gc.get_referrers behavior change 3.6 to 3.7'
updated_at = <Date 2018-09-09.13:54:32.676>
user = 'https://github.com/bryevdv'

bugs.python.org fields:

activity = <Date 2018-09-09.13:54:32.676>
actor = 'methane'
assignee = 'none'
closed = True
closed_date = <Date 2018-09-09.13:54:32.678>
closer = 'methane'
components = ['Library (Lib)']
creation = <Date 2018-09-07.16:30:04.024>
creator = 'bryevdv'
dependencies = []
files = []
hgrepos = []
issue_num = 34608
keywords = []
message_count = 3.0
messages = ['324771', '324819', '324886']
nosy_count = 4.0
nosy_names = ['pitrou', 'benjamin.peterson', 'methane', 'bryevdv']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue34608'
versions = ['Python 3.7']

@bryevdv
Copy link
Mannequin Author

bryevdv mannequin commented Sep 7, 2018

When called on a local object inside a function, gc.get_referrers no longer returns a Frame as one of the references. I could not find anything in the release notes or changeling that indicated that this is an intentional change.

The following script generates different output when run on Python 3.6 vs Python 3.7 (on linux, OSX, or Windows):

# referrers.py
import gc, sys

class FakeMod(object): pass

extra = []

def test():
    mod = FakeMod()
    extra.append(mod)
    referrers = gc.get_referrers(mod)
    print(".".join(str(x) for x in sys.version_info[:3]), ":", len(referrers), referrers)

test()

Output:

~ master*
(py37) ❯ python test.py
3.7.0 : 1 [[<main.FakeMod object at 0x10b65e320>]]

~ master*
(base) ❯ python test.py
3.6.6 : 2 [[<main.FakeMod object at 0x106f3ea90>], <frame object at 0x10684b648>]

@bryevdv bryevdv mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir labels Sep 7, 2018
@benjaminp
Copy link
Contributor

Likely fallout from 5a625d0.

get_referrers() doesn't really guarantee anything. It's more of a clever hack based on however the Python GC works at the moment. So, this it probably WONTFIX.

@methane
Copy link
Member

methane commented Sep 9, 2018

Benjamin is right.
This is very implementation detail. We shouldn't rely on such edge case.

@methane methane closed this as completed Sep 9, 2018
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants