Issue1444

classification
Title: Can't zlib.compress() with array.array('c')
Type: behaviour Severity: major
Components: Library Versions: 2.5.0
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, pjdm, pjenvey
Priority: Keywords:

Created on 2009-08-21.12:26:01 by pjdm, last changed 2009-09-09.05:00:51 by pjenvey.

Messages
msg5060 (view) Author: Peter Mayne (pjdm) Date: 2009-08-21.12:26:00
This program compresses a string and an array.array.

import array
import zlib

INPUT = 'CrunchyFrog'

ci = zlib.compress(INPUT)
print len(ci), repr(ci)

a = array.array('c', INPUT)
ca = zlib.compress(a)
print len(ca), repr(ca)


The output of each print statement in CPython is the same length and
string. Jython 2.5.0 results in

19 'x\x9cs.*\xcdK\xce\xa8t+\xcaO\x07\x00\x1a"\x04k'
Traceback (most recent call last):
  File "ztest.py", line 10, in <module>
    ca = zlib.compress(a)
  File "C:\opt\jython2.5.0\Lib\zlib.py", line 62, in compress
    deflater.setInput(string, 0, len(string))
TypeError: setInput(): 1st arg can't be coerced to byte[]

The result in  this case should be as if zlib.compress() was called with
ca.tostring().
msg5123 (view) Author: Philip Jenvey (pjenvey) Date: 2009-09-09.05:00:49
fixed in r6772
History
Date User Action Args
2009-09-09 05:00:51pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg5123
nosy: + pjenvey
2009-08-21 20:58:48fwierzbickisetnosy: + fwierzbicki
2009-08-21 12:26:25pjdmsettitle: Can't zlib.compress() wuth array.array('c') -> Can't zlib.compress() with array.array('c')
2009-08-21 12:26:01pjdmcreate