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

Add closure variables into global scope #431

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kai3341
Copy link

@kai3341 kai3341 commented Dec 20, 2022

Fixes #430

@kai3341 kai3341 mentioned this pull request Dec 20, 2022
@adamchainz
Copy link
Owner

I think you're off to a good start, but this is failing the tests. Please try running the tests locally with e.g. tox -e py311. Also, add some tests covering class closures, and a chaneglog note.

@kai3341
Copy link
Author

kai3341 commented Jan 4, 2023

I reproduced test fails and fixed it
Also I added new test with my code example. The most funny that these changes are work in my project but the test is failing with initial error which I try to solve
I'll continue working on this issue

globalz = dict(func.__globals__)

for cell in func.__closure__ or ():
cell_contents = cell.cell_contents
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type of cell_contents is Any. So I'm NOT SURE here
Is it better to check if cell_contents is type instance?
What else may it be?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I was right in this question

@adamchainz
Copy link
Owner

Also I added new test with my code example.

I don't see this test? Or a changelog note.

@adamchainz adamchainz changed the title Add add closure variables into global scope Add closure variables into global scope Oct 25, 2024
@adamchainz adamchainz force-pushed the add-variable-lookup-from-closure branch from 98dc6dd to b4f038e Compare October 27, 2024 08:56
@adamchainz
Copy link
Owner

I just added two tests which fail. func.__closure__ is None in the both cases. I'm not sure why it's not there...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Class closures does not work
2 participants