bpo-41194: The _ast module cannot be loaded more than once#21290
Merged
vstinner merged 1 commit intopython:masterfrom Jul 3, 2020
vstinner:fix_ast_state
Merged
bpo-41194: The _ast module cannot be loaded more than once#21290vstinner merged 1 commit intopython:masterfrom vstinner:fix_ast_state
vstinner merged 1 commit intopython:masterfrom
vstinner:fix_ast_state
Conversation
Fix a crash in the _ast module: it can no longer be loaded more than once. It now uses a global state rather than a module state. * Move _ast module state: use a global state instead. * Set _astmodule.m_size to -1, so the extension cannot be loaded more than once.
Member
Author
|
I wrote this change to be able to backport it to Python 3.9, since Python 3.9 is also affected by https://bugs.python.org/issue41194 I don't think that this change goes against https://bugs.python.org/issue38113 intent "Update the Python-ast.c generator to PEP 384". |
Member
Author
|
I will propose a following PR to add again a module state to the _ast module. But for Python 3.9, I prefer to keep a global state, since I'm not 100% confident in such intrusive change, knowing that we are past Python 3.9 feature freeze. |
vstinner
added a commit
that referenced
this pull request
Jul 3, 2020
…21290) (GH-21292) * bpo-41194: Pass module state in Python-ast.c (GH-21284) Rework asdl_c.py to pass the module state to functions in Python-ast.c, instead of using astmodulestate_global. Handle also PyState_AddModule() failure in init_types(). (cherry picked from commit 74419f0) * bpo-41194: The _ast module cannot be loaded more than once (GH-21290) Fix a crash in the _ast module: it can no longer be loaded more than once. It now uses a global state rather than a module state. * Move _ast module state: use a global state instead. * Set _astmodule.m_size to -1, so the extension cannot be loaded more than once. (cherry picked from commit 91e1bc1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix a crash in the _ast module: it can no longer be loaded more than
once. It now uses a global state rather than a module state.
than once.
https://bugs.python.org/issue41194