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: Inconsistent behavior of compressing the BZip2 format
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: niemeyer Nosy List: niemeyer, quiver
Priority: normal Keywords:

Created on 2003-12-03 03:43 by quiver, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg19240 - (view) Author: George Yoshida (quiver) (Python committer) Date: 2003-12-03 03:43
There are three ways to compress data in bz2 but they 
don't handle an empty string same way.
BZ2File and compress can accept an empty string but 
BZ2Compressor raises ValueError.

>>> import bz2
>>> bz2f = bz2.BZ2File('test', 'w')
>>> bz2f.write('')
>>> bz2f.close()
>>> bz2.compress('')
'BZh9\x17rE8P\x90\x00\x00\x00\x00'
>>> bz2c = bz2.BZ2Compressor()
>>> bz2c.compress('')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: the bz2 library has received wrong 
parameters

msg19241 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2004-02-13 20:27
Logged In: YES 
user_id=7887

Indeed, it should be allowed. I'll fix that.

Thanks for your report!
msg19242 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2004-02-14 00:10
Logged In: YES 
user_id=7887

Committed as:

Modules/bz2module.c: 1.22
Misc/NEWS: 1.933
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39649
2003-12-03 03:43:36quivercreate