On Wed, Mar 17, 2021 at 12:11 PM Eric Snow email@example.com wrote:
If that's the case then we're fine. Otherwise there's a viable solution if we want to move ahead with the restriction: add a "legacy" mode for subinterpreters that preserves the current status quo (much like you suggest in https://github.com/ericsnowcurrently/multi-core-python/issues/71).
that indicates the interpreter should operate in "legacy" mode
PyTypeObject.tp_flags (or maybe an enum field, with members INTERP_LEGACY and INTERP_RETRICTED)
PyInterpreterState.config.legacy (or "mode" or whatever)
interpreter's GIL instead of its own
in an ImportError
(or similar; internal-only for now) that would allow setting the mode
This would take care of compatibility with the existing limited API.
FWIW, something like PyInterpreterState.mode has been part of the plan all along. Serendipitously, it happens to fit here. :) Also, restricted mode could include other things, like requiring PEP 489.