[New-bugs-announce] [issue22163] max_wbits set incorrectly to -zlib.MAX_WBITS in tarfile, shouldn't be negative

Eduardo Robles Elvira report at bugs.python.org
Thu Aug 7 13:02:32 CEST 2014

New submission from Eduardo Robles Elvira:

I think I have found a small typo-bug in tarfile.py, that seems to
be present in cpython upstream, which makes tarfile compression slower.
The issue can be seen here, in line 415 [1] of tarfile.py:

        self.cmp = self.zlib.compressobj(9, self.zlib.DEFLATED,

The minus sign doesn't make sense to me, because zlib.MAX_WBITS is 15,
and according to the documentation [2] wbits is by default 15 and
"This should be an integer from 8 to 15. Higher values give better
compression, but use more memory". -15 is not even in range. So I guess the expected value should be the zlib default, 15. Or maybe another value, but it should at least be in range. 

I marked it as "performance" type bug as this only really affects performance.

I might have gotten it all wrong and it's fine the way it is, but I thought it'd be best to report it, as it looked fishy to me.

[1] http://hg.python.org/cpython/file/94d0e842b9ea/Lib/tarfile.py#l415
[2] https://docs.python.org/3.4/library/zlib.html#zlib.compressobj

components: Library (Lib)
files: max_wbits.patch
keywords: patch
messages: 225006
nosy: edulix
priority: normal
severity: normal
status: open
title: max_wbits set incorrectly to -zlib.MAX_WBITS in tarfile, shouldn't be negative
type: performance
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file36299/max_wbits.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list