Message5060

Author pjdm
Recipients pjdm
Date 2009-08-21.12:26:00
SpamBayes Score 3.3567593e-13
Marked as misclassified No
Message-id <1250857561.11.0.0920167531749.issue1444@psf.upfronthosting.co.za>
In-reply-to
Content
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().
History
Date User Action Args
2009-08-21 12:26:01pjdmsetrecipients: + pjdm
2009-08-21 12:26:01pjdmsetmessageid: <1250857561.11.0.0920167531749.issue1444@psf.upfronthosting.co.za>
2009-08-21 12:26:00pjdmlinkissue1444 messages
2009-08-21 12:26:00pjdmcreate