[Python-checkins] bpo-44353: Fix memory leak introduced by GH-27262 (GH-27305)

ambv webhook-mailer at python.org
Fri Jul 23 10:28:17 EDT 2021


https://github.com/python/cpython/commit/8f42106b5c362495f72c6ca2fa3884538e4023db
commit: 8f42106b5c362495f72c6ca2fa3884538e4023db
branch: main
author: Yurii Karabas <1998uriyyo at gmail.com>
committer: ambv <lukasz at langa.pl>
date: 2021-07-23T16:28:05+02:00
summary:

bpo-44353: Fix memory leak introduced by GH-27262 (GH-27305)

files:
M Lib/test/test_typing.py

diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 6f1d4f6ce20e1..ebe6c8d37e501 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -3692,10 +3692,15 @@ def test_c_functions(self):
 
 
 class NewTypeTests:
+    def cleanup(self):
+        for f in self.module._cleanups:
+            f()
+
     def setUp(self):
         sys.modules['typing'] = self.module
 
     def tearDown(self):
+        self.cleanup()
         sys.modules['typing'] = typing
 
     def test_basic(self):
@@ -3738,12 +3743,12 @@ def test_repr(self):
 
         self.assertEqual(repr(UserId), f'{__name__}.UserId')
 
-class NewTypePythonTests(BaseTestCase, NewTypeTests):
+class NewTypePythonTests(NewTypeTests, BaseTestCase):
     module = py_typing
 
 
 @skipUnless(c_typing, 'requires _typing')
-class NewTypeCTests(BaseTestCase, NewTypeTests):
+class NewTypeCTests(NewTypeTests, BaseTestCase):
     module = c_typing
 
 



More information about the Python-checkins mailing list