mirror of
https://github.com/python/cpython.git
synced 2025-11-18 18:31:56 +00:00
Patch #441091 from Finn Bock: the more advanced flush options are not
available in java, so only use the advanced flush options if they are defined in the zlib module.
This commit is contained in:
parent
315cd29ecf
commit
fcfc8d5c0e
1 changed files with 20 additions and 15 deletions
|
|
@ -78,7 +78,10 @@ else:
|
|||
|
||||
# Test flush() with the various options, using all the different levels
|
||||
# in order to provide more variations.
|
||||
for sync in [zlib.Z_NO_FLUSH, zlib.Z_SYNC_FLUSH, zlib.Z_FULL_FLUSH]:
|
||||
sync_opt = ['Z_NO_FLUSH', 'Z_SYNC_FLUSH', 'Z_FULL_FLUSH']
|
||||
sync_opt = [getattr(zlib, opt) for opt in sync_opt if hasattr(zlib, opt)]
|
||||
|
||||
for sync in sync_opt:
|
||||
for level in range(10):
|
||||
obj = zlib.compressobj( level )
|
||||
d = obj.compress( buf[:3000] )
|
||||
|
|
@ -96,6 +99,8 @@ random.seed(1)
|
|||
|
||||
print 'Testing on 17K of random data'
|
||||
|
||||
if hasattr(zlib, 'Z_SYNC_FLUSH'):
|
||||
|
||||
# Create compressor and decompressor objects
|
||||
c=zlib.compressobj(9)
|
||||
d=zlib.decompressobj()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue