summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-09-15 11:55:16 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2014-09-15 11:55:16 (GMT)
commita0f33759fa03a1801f25420e66fab3f2d938244d (patch)
tree296619b9eca5b00fb78a6360129d47ae7e522a60 /Lib
parent0b894b40dba989d8ed3edff310859864748f8848 (diff)
parent8fad1676a215bab3e61dccf0f1802ccb17a43a41 (diff)
downloadcpython-a0f33759fa03a1801f25420e66fab3f2d938244d.zip
cpython-a0f33759fa03a1801f25420e66fab3f2d938244d.tar.gz
cpython-a0f33759fa03a1801f25420e66fab3f2d938244d.tar.bz2
Merge fix for issue #22166 from 3.4
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_codecs.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index f59c37d..c1f54ec 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -2586,6 +2586,14 @@ def _get_test_codec(codec_name):
return _TEST_CODECS.get(codec_name)
codecs.register(_get_test_codec) # Returns None, not usable as a decorator
+try:
+ # Issue #22166: Also need to clear the internal cache in CPython
+ from _codecs import _forget_codec
+except ImportError:
+ def _forget_codec(codec_name):
+ pass
+
+
class ExceptionChainingTest(unittest.TestCase):
def setUp(self):
@@ -2611,6 +2619,12 @@ class ExceptionChainingTest(unittest.TestCase):
def tearDown(self):
_TEST_CODECS.pop(self.codec_name, None)
+ # Issue #22166: Also pop from caches to avoid appearance of ref leaks
+ encodings._cache.pop(self.codec_name, None)
+ try:
+ _forget_codec(self.codec_name)
+ except KeyError:
+ pass
def set_codec(self, encode, decode):
codec_info = codecs.CodecInfo(encode, decode,