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

copy globals() #1150

Merged
merged 2 commits into from
Sep 25, 2023
Merged

copy globals() #1150

merged 2 commits into from
Sep 25, 2023

Conversation

Spitfire1900
Copy link
Contributor

Fixes #1118. Use a copy of globals() rather than a direct reference. This did not appear to impact the time of tests.

@Spitfire1900
Copy link
Contributor Author

Requesting review from @bwendling and @char101 .
Requesting testing from @eunwoosh.

@Spitfire1900

This comment was marked as resolved.

@Spitfire1900

This comment was marked as resolved.

@char101
Copy link
Contributor

char101 commented Sep 23, 2023

If you copy the globals(), isn't the list() part not required anymore?

@char101
Copy link
Contributor

char101 commented Sep 23, 2023

Probably the module is imported twice at the same time, the first import finished the loop a bit faster, and then it adds ISTERMINAL, etc. to the global scope, which broke the second import which is still looping. We could also fix this by moving the loop to the bottom of the file.

@Spitfire1900
Copy link
Contributor Author

So we're using 3.7, so I've elected to use copy() and dictionary comprehension here, while dropping the list() wrapper.

@Spitfire1900
Copy link
Contributor Author

Probably the module is imported twice at the same time, the first import finished the loop a bit faster, and then it adds ISTERMINAL, etc. to the global scope, which broke the second import which is still looping. We could also fix this by moving the loop to the bottom of the file.

This makes logical sense... a bit. I may be out of the loop here but I would think that if a module is imported twice the first import blocks until initialization completes.

@eunwoosh
Copy link

Requesting review from @bwendling and @char101 . Requesting testing from @eunwoosh.

I tested and the error isn't raised anymore. Thanks for fixing it.

@bwendling bwendling merged commit 14c2fbf into google:main Sep 25, 2023
11 checks passed
@Spitfire1900 Spitfire1900 deleted the bugfix/1118/copy-globals() branch September 25, 2023 10:30
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.

error is raised at for _name, _value in list(globals().items()): in yapf_third_party/_ylib2to3/pgen2/token.py
4 participants