Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-29620: iterate over a copy of sys.modules #4800

Merged
merged 2 commits into from
Jun 11, 2020
Merged

Conversation

kernc
Copy link
Contributor

@kernc kernc commented Dec 11, 2017

Fixes https://bugs.python.org/issue29620 by wrapping sys.modules.values() into a tuple before iteration.

https://bugs.python.org/issue29620

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

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).

Lib/unittest/case.py Outdated Show resolved Hide resolved
@kernc
Copy link
Contributor Author

kernc commented Aug 21, 2018

Done. Hope it's ok.

@kernc
Copy link
Contributor Author

kernc commented Aug 22, 2018

Updated. Thanks.

@kernc
Copy link
Contributor Author

kernc commented Sep 17, 2018

@serhiy-storchaka Do you find any other issues?

@lettergram
Copy link

@kernc I'm running into this issue - is it at all possible to prioritize this issue?

@lettergram
Copy link

@serhiy-storchaka Would it be possible to review this PR or is there something I can do?

@kernc kernc changed the title bpo-29620: iterate over a tuple of sys.modules bpo-29620: iterate over a list of sys.modules Oct 29, 2019
@kernc kernc changed the title bpo-29620: iterate over a list of sys.modules bpo-29620: iterate over a copy of sys.modules Oct 29, 2019
@lettergram
Copy link

@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.

@pelillian
Copy link

@serhiy-storchaka Any chance you could take a look at this?

@lettergram
Copy link

@serhiy-storchaka is there anything else required for review?

@csabella csabella requested review from serhiy-storchaka and removed request for serhiy-storchaka January 17, 2020 12:15
@lettergram
Copy link

@akuchling Looks like this is good?

@csabella
Copy link
Contributor

@akuchling, should this be merged? Thanks!

@akuchling akuchling merged commit 46398fb into python:master Jun 11, 2020
@miss-islington
Copy link
Contributor

Thanks @kernc for the PR, and @akuchling for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-bot
Copy link

GH-20816 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 11, 2020
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>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 11, 2020
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>
@bedevere-bot
Copy link

GH-20817 is a backport of this pull request to the 3.7 branch.

akuchling pushed a commit that referenced this pull request Jun 11, 2020
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>
akuchling pushed a commit that referenced this pull request Jun 11, 2020
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>
arun-mani-j pushed a commit to arun-mani-j/cpython that referenced this pull request Jul 21, 2020
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.
@sweeneyde sweeneyde added the needs backport to 3.9 only security fixes label Nov 18, 2021
@miss-islington
Copy link
Contributor

Thanks @kernc for the PR, and @akuchling for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-29605 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Nov 18, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 18, 2021
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>
ambv pushed a commit that referenced this pull request Nov 18, 2021
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants