This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: bz2 error on compression of empty string
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nadeem.vawda Nosy List: doko, gz, jcea, nadeem.vawda, python-dev
Priority: high Keywords: 3.3regression

Created on 2012-12-31 16:58 by gz, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bz2_compress_empty_string_trunk.patch gz, 2012-12-31 17:03 Patch against trunk with tests and fix review
bz2_compress_empty_string_27.patch gz, 2012-12-31 17:12 Patch against 2.7 with same tests and adapted fix
Messages (6)
msg178705 - (view) Author: Martin (gz) * Date: 2012-12-31 16:58
The fix from issue 14398 for >4GB inputs regressed the behaviour when compressing an empty string. Going by issue 853061 the expectation is this should work.

The problem was noticed when using the updated Python 2.7 package in Ubuntu Raring caused test failures in the Bazaar suite:

<https://bugs.launchpad.net/bzr/+bug/1090043>
msg178706 - (view) Author: Martin (gz) * Date: 2012-12-31 17:03
On trunk, both the compressor and the standalone function (which uses the compressor) are affected. The easiest fix is rearranging the logic in function shared between BZ2Compressor.compress and BZ2Compressor.flush so the exit on no remaining input for the former case happens before the library call.
msg178707 - (view) Author: Martin (gz) * Date: 2012-12-31 17:12
On 2.7 only the compress() function is affected, and the fix is much simpler. Just using BZ_FINISH when the input is less then 4GB is sufficient.
msg178826 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2013-01-02 16:56
looks fine to me.
msg178857 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-01-02 22:14
New changeset 06a08144af1b by Nadeem Vawda in branch '2.7':
Issue #16828: Fix error incorrectly raised by bz2.compress('').
http://hg.python.org/cpython/rev/06a08144af1b

New changeset c4a4863b85b2 by Nadeem Vawda in branch '3.2':
Issue #16828: Fix error incorrectly raised by bz2.compress('').
http://hg.python.org/cpython/rev/c4a4863b85b2

New changeset 011981143087 by Nadeem Vawda in branch '3.3':
Issue #16828: Fix error incorrectly raised by bz2.compress('').
http://hg.python.org/cpython/rev/011981143087

New changeset 93654d0d9b1e by Nadeem Vawda in branch '3.3':
Correction: issue #16828 also affects BZ2Compressor.compress().
http://hg.python.org/cpython/rev/93654d0d9b1e

New changeset 44cfd43b09f5 by Nadeem Vawda in branch 'default':
Issue #16828: Fix error incorrectly raised by bz2.compress(b'') and bz2.BZ2Compressor.compress(b'').
http://hg.python.org/cpython/rev/44cfd43b09f5
msg178858 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2013-01-02 22:19
Fixed. Thanks for the bug report and the patches!
History
Date User Action Args
2022-04-11 14:57:40adminsetgithub: 61032
2013-01-02 22:19:42nadeem.vawdasetstatus: open -> closed
messages: + msg178858

assignee: nadeem.vawda
keywords: + 3.3regression, - patch
resolution: fixed
stage: patch review -> resolved
2013-01-02 22:14:31python-devsetnosy: + python-dev
messages: + msg178857
2013-01-02 16:56:55dokosetmessages: + msg178826
2013-01-02 16:43:55dokosetnosy: + doko
2013-01-01 11:56:15pitrousetpriority: normal -> high
2012-12-31 17:23:22serhiy.storchakasetstage: patch review
versions: - Python 3.5
2012-12-31 17:12:07gzsetfiles: + bz2_compress_empty_string_27.patch

messages: + msg178707
2012-12-31 17:06:54jceasetnosy: + jcea
2012-12-31 17:03:25gzsetfiles: + bz2_compress_empty_string_trunk.patch
keywords: + patch
messages: + msg178706
2012-12-31 16:58:04gzcreate