title: Unzip buffer with Python?
body: <p>I have a buffer of bytes read from a library call and I would like to unzip the content which is a single text file. </p>
  
  <p>I tried with <code>zlib</code>, but I get this error:</p>
  
  <pre><code>&gt;&gt;&gt; import zlib
  &gt;&gt;&gt; zlib.decompress(buffer)
  error: Error -3 while decompressing data: incorrect header check
  </code></pre>
  
  <p>However with <code>ZipFile</code> it works, but I have to use a temporary file: </p>
  
  <pre><code>import zipfile
  f = open('foo.zip', 'wb')
  f.write(buffer)
  f.close()
  z = ZipFile('foo.zip')
  z.extractall()
  z.close()
  with open('foo.txt', 'r') as f:
      uncompressed_buffer = f.read()
  </code></pre>
  
  <p>Is it possible to use <code>zlib</code> and how can I avoid using a temporary file?</p>