8000 bpo-41194: The _ast module cannot be loaded more than once by vstinner · Pull Request #21290 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Conversation

vstinner
Copy link
Member
@vstinner vstinner commented Jul 3, 2020

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.

https://bugs.python.org/issue41194

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.
@vstinner
Copy link
Member Author
vstinner commented Jul 3, 2020

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".

cc @DinoV @corona10

@vstinner
Copy link
Member Author
vstinner commented Jul 3, 2020

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 vstinner merged commit 91e1bc1 into python:master Jul 3, 2020
@vstinner vstinner deleted the fix_ast_state branch July 3, 2020 12:15
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)
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.

3 participants
0