Title: _ast module state should be made per interpreter
Type: Stage:
Components: Interpreter Core Versions: Python 3.10
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: petr.viktorin, vstinner
Priority: normal Keywords:

Created on 2020-09-16 10:10 by vstinner, last changed 2020-09-16 14:26 by vstinner.

Messages (3)
msg376983 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-09-16 10:10
In September 2019, the _ast extension module was converted to PEP 384 (stable ABI): bpo-38113.

In bpo-41631, I moved the _ast module state back to a global state, rather than a regular module state, to fix multiple bugs.

The state should be made per intepreter (moved into PyInterpreterState).

Also, each interpreter should have its own _ast types (_ast.AST, _ast.Constant, etc.), rather than sharing all types.

Hopefully, in 3.9, _ast types have been converted to heap types.

To fix bpo-41631, I wanted to convert _ast.AST heap type back into a static type, to prevenet a subinterpreter to modify it, but Petr Viktorin asked me to leave it as it is:

I agree since I would like to convert all static types to heap types: bpo-40077.
msg376989 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2020-09-16 11:53
I started this here:
Feel free to take that code.
msg376996 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-09-16 14:26
> I started this here: Feel free to take that code.

Oh thanks! I was looking for your work, but I failed to find it.

It is really helpful!

I started to hack locally, but Pablo asked me in private to wait a few days, since he is going to push large changes on this file soon.

This issue is an enhancement which can wait.
Date User Action Args
2020-09-16 14:26:30vstinnersetmessages: + msg376996
2020-09-16 11:53:38petr.viktorinsetnosy: + petr.viktorin
messages: + msg376989
2020-09-16 10:10:24vstinnercreate