mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Fix RuntimeError on sys.modules in reset_warning_registry
Django 1.8's reset_warning_registry (which we backport) was generating `RuntimeError: dictionary changed size during iteration` in Travis tests under Python 3.x. Likely a thread-safety issue on sys.modules.values(). See https://code.djangoproject.com/ticket/21049 for fix applied elsewhere in Django.
This commit is contained in:
@@ -91,6 +91,7 @@ class BackportedAssertions(object):
|
||||
|
||||
|
||||
# Backport from Django 1.8 (django.test.utils)
|
||||
# with fix suggested by https://code.djangoproject.com/ticket/21049
|
||||
def reset_warning_registry():
|
||||
"""
|
||||
Clear warning registry for all modules. This is required in some tests
|
||||
@@ -100,6 +101,6 @@ def reset_warning_registry():
|
||||
The bug was fixed in Python 3.4.2.
|
||||
"""
|
||||
key = "__warningregistry__"
|
||||
for mod in sys.modules.values():
|
||||
for mod in list(sys.modules.values()):
|
||||
if hasattr(mod, key):
|
||||
getattr(mod, key).clear()
|
||||
|
||||
Reference in New Issue
Block a user