
Tim Peters wrote:
No more than self-consistency, I expect, same as for a proper call now run from a thread.
That covers the case that proper calls are possible from this thread (although there are still ambiguities: a single that may have multiple thread states, which are associated to multiple interpreters, which may have diffent contents of sys.modules) However, that answer does not work for the case for a thread that has never seen a Python call: proper calls could not run on this thread.
Then I expect the strongest that can be said is that the output you get corresponds to the actual state of sys.modules at some time T
The issue is that there may be multiple sys.modules in the process, at T. Then the question is whether to use one of the existing ones (if so: which one), or create a new one.
I don't expect we can say anything stronger than that today either.
Currently, the extension author must somehow come up with an interpreter state. I'm uncertain whether you are proposing to leave it at that, or whether you require that any solution to "the problem" also provides a way to obtain the "right" interpreter state somehow. Regards, Martin