STINNER Victor <[email protected]> added the comment:
> Compared to Python 3.8, PR 21961 has no regression related to subinterpreters.
Oh. I forgot that static types cannot be modified (in Python, but it's possible
in C). So my PR still changed the behavior compared to 3.8:
---
import _testcapi
import _ast
res = _testcapi.run_in_subinterp("import _ast; _ast.AST.x = 1")
if res != 0:
raise Exception("bug")
print(_ast.AST.x)
---
On Python 3.8, this code snippet fails with:
TypeError: can't set attributes of built-in/extension type '_ast.AST'
On master, it is possible to modify or add an _ast.AST attribute. Since PR
21961 moves back to a global strange, Petr is correct that a subinterpreter can
now modify the state of another subinterpreter the _ast.AST type.
So I modified my PR 21961 to revert partially the change which converted
AST_type type from a static type to a heap type.
My PR 21961 converts AST_type back to a static type, to avoid these problems.
Sadly, it makes _ast module incompatible with PEP 384, but the priority is to
fix this 3rd regression. We can reconsider converting PEP 384 back to a heap
type later, but we will have to be careful with not reintroducing all these
bugs.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41631>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com