New submission from Patrick Bourke <pbou...@microsoft.com>:
Hi all, Forgive me if this is not the correct way to report this, but we have run into the issue from #29620 ( https://bugs.python.org/issue29620 ) on Python 3.9. The fix appears to be present in the tip of 3.8: https://github.com/python/cpython/blob/c37a0d9c0ae4aa0d9135fac9a58afc7b34ff71d6/Lib/unittest/case.py#L254 and 3.10: https://github.com/python/cpython/blob/0ef308a2890571c850c624fb99ac00f8951363c6/Lib/unittest/case.py#L255 but missing from 3.9: https://github.com/python/cpython/blob/0ef308a2890571c850c624fb99ac00f8951363c6/Lib/unittest/case.py#L255 Here is our test case: import unittest import graspologic class MyTestCase(unittest.TestCase): def test_something(self): with self.assertWarns(UserWarning): pass if __name__ == '__main__': unittest.main() fails with: ====================================================================== ERROR: test_something (__main__.MyTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\pbourke\AppData\Roaming\JetBrains\PyCharm2021.2\scratches\test.py", line 7, in test_something with self.assertWarns(UserWarning): File "C:\Users\pbourke\.pyenv\pyenv-win\versions\3.9.7\lib\unittest\case.py", line 255, in __enter__ for v in sys.modules.values(): RuntimeError: dictionary changed size during iteration The module triggering the error appears to be IPython.utils.io, which is included somewhere in our dependencies. My CPython is: Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] ---------- components: Library (Lib) messages: 406516 nosy: pbourke priority: normal severity: normal status: open title: unittest.TestCase.assertWarns raises RuntimeEror if sys.modules changes size (Python 3.9) type: behavior versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45836> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com