diff options
author | Oren Milman <orenmn@gmail.com> | 2018-02-13 10:28:33 (GMT) |
---|---|---|
committer | INADA Naoki <methane@users.noreply.github.com> | 2018-02-13 10:28:33 (GMT) |
commit | d019bc8319ea35e93bf4baa38098ff1b57cd3ee5 (patch) | |
tree | d9b927eba02059f8be8465d35b6969254b172b8e /Lib/test/test_lzma.py | |
parent | aec7532ed3ccbd29d3429a3f375e25f956c44003 (diff) | |
download | cpython-d019bc8319ea35e93bf4baa38098ff1b57cd3ee5.zip cpython-d019bc8319ea35e93bf4baa38098ff1b57cd3ee5.tar.gz cpython-d019bc8319ea35e93bf4baa38098ff1b57cd3ee5.tar.bz2 |
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
Diffstat (limited to 'Lib/test/test_lzma.py')
-rw-r--r-- | Lib/test/test_lzma.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_lzma.py b/Lib/test/test_lzma.py index d7a8576..3dc2c1e 100644 --- a/Lib/test/test_lzma.py +++ b/Lib/test/test_lzma.py @@ -4,6 +4,8 @@ import os import pathlib import pickle import random +import sys +from test import support import unittest from test.support import ( @@ -364,6 +366,15 @@ class CompressorDecompressorTestCase(unittest.TestCase): with self.assertRaises(TypeError): pickle.dumps(LZMADecompressor(), proto) + @support.refcount_test + def test_refleaks_in_decompressor___init__(self): + gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount') + lzd = LZMADecompressor() + refs_before = gettotalrefcount() + for i in range(100): + lzd.__init__() + self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10) + class CompressDecompressFunctionTestCase(unittest.TestCase): |