bpo-29620: iterate over a copy of sys.modules#4800
Conversation
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Could you please add a test? It is enough to create a types.ModuleType subclass with the __warningregistry__ property (or the __getattr__() method) which mutates sys.modules and add its instance to sys.modules.
Add also a news entry (see https://devguide.python.org/committing/#what-s-new-and-news-entries).
|
Done. Hope it's ok. |
|
Updated. Thanks. |
|
@serhiy-storchaka Do you find any other issues? |
|
@kernc I'm running into this issue - is it at all possible to prioritize this issue? |
|
@serhiy-storchaka Would it be possible to review this PR or is there something I can do? |
|
@serhiy-storchaka If there's any way either myself or @kernc could help, please let me know! If there's someone else / something else we need to do please let us know. |
|
@serhiy-storchaka Any chance you could take a look at this? |
|
@serhiy-storchaka is there anything else required for review? |
|
@akuchling Looks like this is good? |
|
@akuchling, should this be merged? Thanks! |
|
Thanks @kernc for the PR, and @akuchling for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8. |
|
GH-20816 is a backport of this pull request to the 3.8 branch. |
unittest.TestCase.assertWarns no longer raises a RuntimeException when accessing a module's ``__warningregistry__`` causes importation of a new module, or when a new module is imported in another thread. Patch by Kernc. (cherry picked from commit 46398fb) Co-authored-by: kernc <kerncece@gmail.com>
unittest.TestCase.assertWarns no longer raises a RuntimeException when accessing a module's ``__warningregistry__`` causes importation of a new module, or when a new module is imported in another thread. Patch by Kernc. (cherry picked from commit 46398fb) Co-authored-by: kernc <kerncece@gmail.com>
|
GH-20817 is a backport of this pull request to the 3.7 branch. |
unittest.TestCase.assertWarns no longer raises a RuntimeException when accessing a module's ``__warningregistry__`` causes importation of a new module, or when a new module is imported in another thread. (cherry picked from commit 46398fb) Co-authored-by: kernc <kerncece@gmail.com>
unittest.TestCase.assertWarns no longer raises a RuntimeException when accessing a module's ``__warningregistry__`` causes importation of a new module, or when a new module is imported in another thread. (cherry picked from commit 46398fb) Co-authored-by: kernc <kerncece@gmail.com>
|
Thanks @kernc for the PR, and @akuchling for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
|
GH-29605 is a backport of this pull request to the 3.9 branch. |
unittest.TestCase.assertWarns no longer raises a RuntimeException when accessing a module's ``__warningregistry__`` causes importation of a new module, or when a new module is imported in another thread. Patch by Kernc. (cherry picked from commit 46398fb) Co-authored-by: kernc <kerncece@gmail.com>
unittest.TestCase.assertWarns no longer raises a RuntimeException when accessing a module's ``__warningregistry__`` causes importation of a new module, or when a new module is imported in another thread. Patch by Kernc. (cherry picked from commit 46398fb) Co-authored-by: kernc <kerncece@gmail.com>
Fixes https://bugs.python.org/issue29620 by wrapping
sys.modules.values()into a tuple before iteration.https://bugs.python.org/issue29620