bpo-27535: Fix memory leak with warnings ignore (#4489)

The warnings module doesn't leak memory anymore in the hidden
warnings registry for the "ignore" action of warnings filters.

The warn_explicit() function doesn't add the warning key to the
registry anymore for the "ignore" action.
This commit is contained in:
Victor Stinner 2017-11-27 16:57:07 +01:00 committed by GitHub
parent 21c7730761
commit c9758784eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 5 deletions

View file

@ -125,6 +125,7 @@ class FilterTests(BaseTest):
self.module.filterwarnings("ignore", category=UserWarning)
self.module.warn("FilterTests.test_ignore", UserWarning)
self.assertEqual(len(w), 0)
self.assertEqual(list(__warningregistry__), ['version'])
def test_ignore_after_default(self):
with original_warnings.catch_warnings(record=True,