Andrei Kulakov <andrei....@gmail.com> added the comment:

I've been looking into avoiding global modification of modules['__main__'], the 
options are:

 1. remove the test and leave it at that

 2. remove the test and open a new issue for re-adding a test ; and look for a 
way to do it safely

 3. create a temp script file, add code to it that creates a class, sets 
`sys.modules['__main__'].__file__ = None` and inspects the class, and run this 
module in a new interpreter, checks exception raised and does sys.exit(1); and 
check the exit code after running this script.

 4. patch inspect.sys.modules; as far as I understand, this would mean other 
modules accessing sys.modules in other threads won't be affected, and 
sys.modules['__main__'] is currently used in inspect in a very limited way, so 
it can probably be shown that this patching won't affect other tests that use 
inspect, -- but I would need to look more into this.

I'm not sure if #3 is too heavy/complex for this test.

The advantage of #1 and #2 is that it's easy to do and ensures that there won't 
be strange random test failures that are hard to track down and debug (which is 
something that I'm afraid can happen right now, caused by this test).

#4 I've added to get comments / thought.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44808>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to