summaryrefslogtreecommitdiff
path: root/Lib/test/test_lzma.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-02-13 03:32:18 -0800
committerGitHub <noreply@github.com>2018-02-13 03:32:18 -0800
commitef20abed7f2ae0ba54b1d287f5fe601be80c1128 (patch)
tree8c744e5c7df5b8b200f85898b02f724247d870b0 /Lib/test/test_lzma.py
parent9b5a90b975ef32b261d60b8ec06504f4ffd00d63 (diff)
downloadcpython-git-ef20abed7f2ae0ba54b1d287f5fe601be80c1128.tar.gz
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
(cherry picked from commit d019bc8319ea35e93bf4baa38098ff1b57cd3ee5) Co-authored-by: Oren Milman <orenmn@gmail.com>
Diffstat (limited to 'Lib/test/test_lzma.py')
-rw-r--r--Lib/test/test_lzma.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_lzma.py b/Lib/test/test_lzma.py
index d7a8576d51..3dc2c1e7e3 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):