From c1445136cbfcf530ead43b80e303d2df03e94c99 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Fri, 26 Jan 2018 17:00:54 +0100 Subject: [PATCH 1/8] issue 32682: test_zlib improve version parsing --- Lib/test/test_zlib.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index e67bee97cb3d3be..ee1d6e536fe58a9 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -751,7 +751,12 @@ def test_large_unconsumed_tail(self, size): def test_wbits(self): # wbits=0 only supported since zlib v1.2.3.5 # Register "1.2.3" as "1.2.3.0" - v = (zlib.ZLIB_RUNTIME_VERSION + ".0").split(".", 4) + if zlib.ZLIB_RUNTIME_VERSION.find('-')>=0: + # zlib can report "1.2.8-linuxfoundation-mods-v1 or "1.2.8.f-linuxfoundation-mods-v1" + v = list(map( int , zlib.ZLIB_RUNTIME_VERSION.split('-',1)[0].split('.')[:3] )) + v.append(0) + else: + v = (zlib.ZLIB_RUNTIME_VERSION + ".0").split(".", 4) supports_wbits_0 = int(v[0]) > 1 or int(v[0]) == 1 \ and (int(v[1]) > 2 or int(v[1]) == 2 and (int(v[2]) > 3 or int(v[2]) == 3 and int(v[3]) >= 5)) From e88a7123a19a3a94fb9283c6c309499dc4f836ce Mon Sep 17 00:00:00 2001 From: pmp-p Date: Fri, 26 Jan 2018 18:18:13 +0100 Subject: [PATCH 2/8] simplify as requested --- Lib/test/test_zlib.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index ee1d6e536fe58a9..fd5de5aa951fcd4 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -751,12 +751,11 @@ def test_large_unconsumed_tail(self, size): def test_wbits(self): # wbits=0 only supported since zlib v1.2.3.5 # Register "1.2.3" as "1.2.3.0" - if zlib.ZLIB_RUNTIME_VERSION.find('-')>=0: - # zlib can report "1.2.8-linuxfoundation-mods-v1 or "1.2.8.f-linuxfoundation-mods-v1" - v = list(map( int , zlib.ZLIB_RUNTIME_VERSION.split('-',1)[0].split('.')[:3] )) + v = zlib.ZLIB_RUNTIME_VERSION.split('-',1)[0] + if '-' in v: + v = list(map( int , v.split('.')[:3] )) v.append(0) - else: - v = (zlib.ZLIB_RUNTIME_VERSION + ".0").split(".", 4) + supports_wbits_0 = int(v[0]) > 1 or int(v[0]) == 1 \ and (int(v[1]) > 2 or int(v[1]) == 2 and (int(v[2]) > 3 or int(v[2]) == 3 and int(v[3]) >= 5)) From a2a95713bf009da284a8dfba26090e3801b5ab97 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Fri, 26 Jan 2018 18:21:18 +0100 Subject: [PATCH 3/8] Update test_zlib.py --- Lib/test/test_zlib.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index fd5de5aa951fcd4..de9ee29367a28a2 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -751,11 +751,12 @@ def test_large_unconsumed_tail(self, size): def test_wbits(self): # wbits=0 only supported since zlib v1.2.3.5 # Register "1.2.3" as "1.2.3.0" - v = zlib.ZLIB_RUNTIME_VERSION.split('-',1)[0] + v = zlib.ZLIB_RUNTIME_VERSION if '-' in v: - v = list(map( int , v.split('.')[:3] )) - v.append(0) - + v = v.split('-',1)[0].split('.')[:3] + v.append('0') + else: + v = (v + ".0").split(".", 4) supports_wbits_0 = int(v[0]) > 1 or int(v[0]) == 1 \ and (int(v[1]) > 2 or int(v[1]) == 2 and (int(v[2]) > 3 or int(v[2]) == 3 and int(v[3]) >= 5)) From c6d42d621a3679bd4cafe542309dfe80fc8a44b9 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Fri, 26 Jan 2018 18:52:13 +0100 Subject: [PATCH 4/8] Update test_zlib.py --- Lib/test/test_zlib.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index de9ee29367a28a2..21c89b32ddfcdb7 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -750,17 +750,19 @@ def test_large_unconsumed_tail(self, size): def test_wbits(self): # wbits=0 only supported since zlib v1.2.3.5 - # Register "1.2.3" as "1.2.3.0" - v = zlib.ZLIB_RUNTIME_VERSION - if '-' in v: - v = v.split('-',1)[0].split('.')[:3] + # Register "1.2.3" as "1.2.3.0" or "1.2.0-linux","1.2.0.f","1.2.0.f-linux" + v = zlib.ZLIB_RUNTIME_VERSION.split('-',1)[0].split('.') + if len(v)<4: v.append('0') - else: - v = (v + ".0").split(".", 4) - supports_wbits_0 = int(v[0]) > 1 or int(v[0]) == 1 \ - and (int(v[1]) > 2 or int(v[1]) == 2 - and (int(v[2]) > 3 or int(v[2]) == 3 and int(v[3]) >= 5)) - + elif not v[-1].isnumeric(): + v[-1]='0' + + v = tuple( map( int, v ) ) + supports_wbits_0 = (v[0]> 1) or ( v[0] == 1 ) \ + and ( v[1] > 2 ) or ( v[1] == 2 ) \ + and ( v[2] > 3 ) or ( v[2] == 3) \ + and ( v[3] >= 5) + co = zlib.compressobj(level=1, wbits=15) zlib15 = co.compress(HAMLET_SCENE) + co.flush() self.assertEqual(zlib.decompress(zlib15, 15), HAMLET_SCENE) From bcb3c789da0c2f53a3f6061690e5520f32ef2f9c Mon Sep 17 00:00:00 2001 From: pmp-p Date: Fri, 26 Jan 2018 19:16:22 +0100 Subject: [PATCH 5/8] Update test_zlib.py --- Lib/test/test_zlib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 21c89b32ddfcdb7..36ca5ff17ecf71c 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -750,7 +750,8 @@ def test_large_unconsumed_tail(self, size): def test_wbits(self): # wbits=0 only supported since zlib v1.2.3.5 - # Register "1.2.3" as "1.2.3.0" or "1.2.0-linux","1.2.0.f","1.2.0.f-linux" + # Register "1.2.3" as "1.2.3.0" + # or "1.2.0-linux","1.2.0.f","1.2.0.f-linux" v = zlib.ZLIB_RUNTIME_VERSION.split('-',1)[0].split('.') if len(v)<4: v.append('0') @@ -762,6 +763,7 @@ def test_wbits(self): and ( v[1] > 2 ) or ( v[1] == 2 ) \ and ( v[2] > 3 ) or ( v[2] == 3) \ and ( v[3] >= 5) + del v co = zlib.compressobj(level=1, wbits=15) zlib15 = co.compress(HAMLET_SCENE) + co.flush() From 1c7d5360244521c65a603c0edef5b2383f325a33 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Fri, 26 Jan 2018 19:28:59 +0100 Subject: [PATCH 6/8] out of space --- Lib/test/test_zlib.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 36ca5ff17ecf71c..f05bb47a2a95c59 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -752,19 +752,19 @@ def test_wbits(self): # wbits=0 only supported since zlib v1.2.3.5 # Register "1.2.3" as "1.2.3.0" # or "1.2.0-linux","1.2.0.f","1.2.0.f-linux" - v = zlib.ZLIB_RUNTIME_VERSION.split('-',1)[0].split('.') - if len(v)<4: + v = zlib.ZLIB_RUNTIME_VERSION.split('-', 1)[0].split('.') + if len(v) < 4: v.append('0') elif not v[-1].isnumeric(): - v[-1]='0' + v[-1] = '0' v = tuple( map( int, v ) ) - supports_wbits_0 = (v[0]> 1) or ( v[0] == 1 ) \ - and ( v[1] > 2 ) or ( v[1] == 2 ) \ - and ( v[2] > 3 ) or ( v[2] == 3) \ - and ( v[3] >= 5) + supports_wbits_0 = ( v[0] > 1 ) or ( v[0] == 1 ) \ + and ( v[1] > 2 ) or ( v[1] == 2 ) \ + and ( v[2] > 3 ) or ( v[2] == 3 ) \ + and ( v[3] >= 5 ) del v - + co = zlib.compressobj(level=1, wbits=15) zlib15 = co.compress(HAMLET_SCENE) + co.flush() self.assertEqual(zlib.decompress(zlib15, 15), HAMLET_SCENE) From 825593776075c01da0a80b6af9c66e6b89dca645 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Mon, 5 Feb 2018 18:40:06 +0100 Subject: [PATCH 7/8] Update test_zlib.py --- Lib/test/test_zlib.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index f05bb47a2a95c59..071ee2e6517f2f3 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -758,12 +758,8 @@ def test_wbits(self): elif not v[-1].isnumeric(): v[-1] = '0' - v = tuple( map( int, v ) ) - supports_wbits_0 = ( v[0] > 1 ) or ( v[0] == 1 ) \ - and ( v[1] > 2 ) or ( v[1] == 2 ) \ - and ( v[2] > 3 ) or ( v[2] == 3 ) \ - and ( v[3] >= 5 ) - del v + v = tuple(map(int, v)) + supports_wbits_0 = v >= (1, 2, 3, 5) co = zlib.compressobj(level=1, wbits=15) zlib15 = co.compress(HAMLET_SCENE) + co.flush() From 2e9307df7bff237f128354472dcb66f37ea2eb33 Mon Sep 17 00:00:00 2001 From: pmp-p Date: Mon, 5 Feb 2018 19:00:55 +0100 Subject: [PATCH 8/8] Update test_zlib.py --- Lib/test/test_zlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 071ee2e6517f2f3..db950fc1907a942 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -759,7 +759,7 @@ def test_wbits(self): v[-1] = '0' v = tuple(map(int, v)) - supports_wbits_0 = v >= (1, 2, 3, 5) + supports_wbits_0 = v >= (1, 2, 3, 5) co = zlib.compressobj(level=1, wbits=15) zlib15 = co.compress(HAMLET_SCENE) + co.flush()