Issue #22995: Backported additional tests for non-pickleable types.
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index fb62081..c8fc985 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -1,6 +1,7 @@
 import unittest
 from test.test_support import TESTFN, run_unittest, import_module, unlink, requires
 import binascii
+import pickle
 import random
 from test.test_support import precisionbigmemtest, _1G, _4G
 import sys
@@ -502,6 +503,16 @@
         d.flush()
         self.assertRaises(ValueError, d.copy)
 
+    def test_compresspickle(self):
+        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+            with self.assertRaises((TypeError, pickle.PicklingError)):
+                pickle.dumps(zlib.compressobj(zlib.Z_BEST_COMPRESSION), proto)
+
+    def test_decompresspickle(self):
+        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+            with self.assertRaises((TypeError, pickle.PicklingError)):
+                pickle.dumps(zlib.decompressobj(), proto)
+
     # Memory use of the following functions takes into account overallocation
 
     @precisionbigmemtest(size=_1G + 1024 * 1024, memuse=3)