Generate 16+MAX_WBITS decompressable data

Discussion in 'Python' started by Fayaz Yusuf Khan, Feb 12, 2013.

  1. I'm trying write unit-tests for some of my old code and have run into this
    piece of code.

    dcomp = zlib.decompressobj(16+zlib.MAX_WBITS)
    chunk = ''.join(f.chunks())
    received_data = dcomp.decompress(chunk)

    How do I generate the chunk here? From what I've been trying I'm getting
    this exception:
    >>> import zlib
    >>> zlib.compress('hello')

    'x\x9c\xcbH\xcd\xc9\xc9\x07\x00\x06,\x02\x15'
    >>> zlib.decompress(_, 16+zlib.MAX_WBITS)

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    zlib.error: Error -3 while decompressing data: incorrect header check

    zlib.decompress without the second argument works, but I can't really go
    ahead into my project file and remove it.
    --
    Fayaz Yusuf Khan
    Cloud architect, Dexetra SS, India
    fayaz.yusuf.khan_AT_gmail_DOT_com, fayaz_AT_dexetra_DOT_com
    +91-9746-830-823
    Fayaz Yusuf Khan, Feb 12, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. C T
    Replies:
    3
    Views:
    2,403
    Charles M. Elias
    Mar 5, 2004
  2. Weng Tianxiang
    Replies:
    5
    Views:
    1,288
    Christophe
    Feb 16, 2006
  3. Replies:
    3
    Views:
    386
    red floyd
    Apr 7, 2006
  4. Harlan Messinger
    Replies:
    2
    Views:
    2,271
    John Bell
    Mar 28, 2010
  5. Terry Reedy
    Replies:
    2
    Views:
    164
    Terry Reedy
    Feb 13, 2013
Loading...

Share This Page