Author vstinner
Recipients BTaskaya, corona10, dino.viehland, eric.snow, lukasz.langa, mjacob, pablogsal, petr.viktorin, shihai1991, vstinner
Date 2020-09-11.09:30:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1599816603.26.0.5980865651.issue41631@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2020-09-11 09:30:03vstinnersetrecipients: + vstinner, dino.viehland, petr.viktorin, lukasz.langa, eric.snow, mjacob, corona10, pablogsal, BTaskaya, shihai1991
2020-09-11 09:30:03vstinnersetmessageid: <1599816603.26.0.5980865651.issue41631@roundup.psfhosted.org>
2020-09-11 09:30:03vstinnerlinkissue41631 messages
2020-09-11 09:30:02vstinnercreate