[issue40600] Add option to disallow > 1 instance of an extension module
Dong-hee Na
report at bugs.python.org
Thu Sep 10 04:58:38 EDT 2020
Dong-hee Na <donghee.na92 at gmail.com> added the comment:
One of my opinions is that
Since module object supports detecting error during Py_mod_exec,
The only thing we have to do is return -1 when the module has already existed.
we should define new exception type and don't have to define new slots.
The pros of this method is that we don't have to modify module object and no needs to write the new PEP
but the cons of this method is that we should promise the standard exception when try to create multiple instances which is not allowed.
ref:
https://github.com/python/cpython/blob/788b79fa7b6184221e68d4f1a3fbe0b3270693f6/Objects/moduleobject.c#L399
On the other side, defining a Py_mod_exec_once that supports execution for just once can be a way.
Although the usage is little, it will be fine because the use case will exist.
Please point out what I missed :)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40600>
_______________________________________
More information about the Python-bugs-list
mailing list