@@ -34,8 +34,9 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
3434ZLIB_RUNTIME_VERSION_TUPLE = _zlib_runtime_version_tuple ()
3535
3636
37- # bpo-46623: On s390x, when a hardware accelerator is used, using different
38- # ways to compress data with zlib can produce different compressed data.
37+ # bpo-46623: When a hardware accelerator is used (currently only on s390x),
38+ # using different ways to compress data with zlib can produce different
39+ # compressed data.
3940# Simplified test_pair() code:
4041#
4142# def func1(data):
@@ -58,10 +59,10 @@ def _zlib_runtime_version_tuple(zlib_version=zlib.ZLIB_RUNTIME_VERSION):
5859#
5960# zlib.decompress(func1(data)) == zlib.decompress(func2(data)) == data
6061#
61- # Make the assumption that s390x always has an accelerator to simplify the skip
62- # condition. Windows doesn't have os.uname() but it doesn't support s390x .
63- skip_on_s390x = unittest . skipIf ( hasattr ( os , 'uname' ) and os .uname (). machine == ' s390x' ,
64- 'skipped on s390x')
62+ # To simplify the skip condition, make the assumption that s390x always has an
63+ # accelerator, and nothing else has it .
64+ # Windows doesn't have os.uname() but it doesn't support s390x.
65+ HW_ACCELERATED = hasattr ( os , 'uname' ) and os . uname (). machine == ' s390x'
6566
6667
6768class VersionTestCase (unittest .TestCase ):
@@ -227,12 +228,14 @@ def test_keywords(self):
227228 bufsize = zlib .DEF_BUF_SIZE ),
228229 HAMLET_SCENE )
229230
230- @skip_on_s390x
231231 def test_speech128 (self ):
232232 # compress more data
233233 data = HAMLET_SCENE * 128
234234 x = zlib .compress (data )
235- self .assertEqual (zlib .compress (bytearray (data )), x )
235+ # With hardware acceleration, the compressed bytes
236+ # might not be identical.
237+ if not HW_ACCELERATED :
238+ self .assertEqual (zlib .compress (bytearray (data )), x )
236239 for ob in x , bytearray (x ):
237240 self .assertEqual (zlib .decompress (ob ), data )
238241
@@ -279,7 +282,6 @@ def test_64bit_compress(self, size):
279282
280283class CompressObjectTestCase (BaseCompressTestCase , unittest .TestCase ):
281284 # Test compression object
282- @skip_on_s390x
283285 def test_pair (self ):
284286 # straightforward compress/decompress objects
285287 datasrc = HAMLET_SCENE * 128
@@ -290,7 +292,10 @@ def test_pair(self):
290292 x1 = co .compress (data )
291293 x2 = co .flush ()
292294 self .assertRaises (zlib .error , co .flush ) # second flush should not work
293- self .assertEqual (x1 + x2 , datazip )
295+ # With hardware acceleration, the compressed bytes might not
296+ # be identical.
297+ if not HW_ACCELERATED :
298+ self .assertEqual (x1 + x2 , datazip )
294299 for v1 , v2 in ((x1 , x2 ), (bytearray (x1 ), bytearray (x2 ))):
295300 dco = zlib .decompressobj ()
296301 y1 = dco .decompress (v1 + v2 )
0 commit comments