On 2020-04-22 08:05, Glenn Linderman wrote:
On 4/21/2020 10:26 PM, Greg Ewing wrote:
And if I understand correctly, you won't get any nice "This
module does not support subinterpreters" exception if you
import an incompatible module -- just an obscure crash,
probably of the core-dumping variety.

This sounds fixable: modules that support subinterpreters should set a flag saying so, and the either the load of a non-flagged module when subinterpreters are in use, or the initiation of a subinterpreter when a non-flagged module has been loaded, should raise.


There was talk about making a orthogonal flag just for opting into subinterpreter support. But what you use now as such a flag is multi-phase initialization: https://docs.python.org/3/c-api/module.html?highlight=pymodule_fromdefandspec#multi-phase-initialization

(Though I like the PEP 489 wording, "expected to support subinterpreters and multiple Py_Initialize/Py_Finalize cycles correctly", better than what ended up in the docs.)


The simplest strategy to support subinterpreters correctly is to refuse to create the extension module more than once per process (with an appropriate error, of course).
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/5J5XTTDUKZWEVDSU3V67W3FYOY7VA7UO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to