aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_zlib.py
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-04-30 16:04:57 +0200
committerGitHub <noreply@github.com>2021-04-30 16:04:57 +0200
commit9746cda705decebc0ba572d95612796afd06dcd4 (patch)
treed21d7082061099687919b8e744250bb39cf5613d /Lib/test/test_zlib.py
parent387397f8a4244c983f4568c16a28842e3268fe5d (diff)
downloadcpython-9746cda705decebc0ba572d95612796afd06dcd4.tar.gz
cpython-9746cda705decebc0ba572d95612796afd06dcd4.zip
bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)
Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to the following types: * _dbm.dbm * _gdbm.gdbm * _multibytecodec.MultibyteCodec * _sre..SRE_Scanner * _thread._localdummy * _thread.lock * _winapi.Overlapped * array.arrayiterator * functools.KeyWrapper * functools._lru_list_elem * pyexpat.xmlparser * re.Match * re.Pattern * unicodedata.UCD * zlib.Compress * zlib.Decompress
Diffstat (limited to 'Lib/test/test_zlib.py')
-rw-r--r--Lib/test/test_zlib.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 7f30cac64f7..694ef6e4875 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -129,6 +129,14 @@ class ExceptionTestCase(unittest.TestCase):
with self.assertRaisesRegex(OverflowError, 'int too large'):
zlib.decompressobj().flush(sys.maxsize + 1)
+ @support.cpython_only
+ def test_disallow_instantiation(self):
+ # Ensure that the type disallows instantiation (bpo-43916)
+ comp_type = type(zlib.compressobj())
+ decomp_type = type(zlib.decompressobj())
+ self.assertRaises(TypeError, comp_type)
+ self.assertRaises(TypeError, decomp_type)
+
class BaseCompressTestCase(object):
def check_big_compress_buffer(self, size, compress_func):