◐ Shell
clean mode source ↗

bpo-40173: Remove redundant import module of import_fresh_module() by shihai1991 · Pull Request #19390 · python/cpython

@shihai1991 shihai1991 changed the title WIP: Remove redundant import module of import_fresh_module() bpo-40173: Remove redundant import module of import_fresh_module()

Apr 6, 2020

iritkatriel

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR needs a unit test.

@shihai1991

This PR needs a unit test.

Thanks for your comment. I have forget this PR's detail. test.support need many test cases.
After we make sure this PR can fix the issue, I can add some test cases.

@iritkatriel

Up to you, but I think it will be easier for reviewers to see what issue the PR is trying to fix if it included tests.

serhiy-storchaka

Comment on lines +245 to +246

sys.modules.clear()
sys.modules.update(orig_modules)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered this option, but some modules can not support re-importing. So it is safer to restore only explicitly mentioned modules and their submodules.
See #28654.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, Serhiy. I missed your PR :(