Message398788
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. |
|
Date |
User |
Action |
Args |
2021-08-02 17:59:16 | andrei.avk | set | recipients:
+ andrei.avk, lukasz.langa, Mark.Shannon, pablogsal, miss-islington |
2021-08-02 17:59:16 | andrei.avk | set | messageid: <1627927156.78.0.931584945864.issue44808@roundup.psfhosted.org> |
2021-08-02 17:59:16 | andrei.avk | link | issue44808 messages |
2021-08-02 17:59:16 | andrei.avk | create | |
|