title: Convert from '_io.BytesIO' to a bytes-like object in python3.6?
body: <p>I am using this function to uncompress the body or a HTTP response if it is compressed with gzip, compress or deflate.</p>
  <pre><code>def uncompress_body(self, compression_type, body):
      if compression_type == 'gzip' or compression_type == 'compress':
          return zlib.decompress(body)
      elif compression_type == 'deflate':
          compressor = zlib.compressobj(9, zlib.DEFLATED, -zlib.MAX_WBITS)
          compressed = compressor.compress(body)
          compressed += compressor.flush()
          return base64.b64encode(compressed)
  
      return body
  </code></pre>
  <p>However python throws this error message.</p>
  <pre><code>TypeError: a bytes-like object is required, not '_io.BytesIO'
  </code></pre>
  <p>on this line:</p>
  <pre><code>return zlib.decompress(body)
  </code></pre>
  <p>Essentially, how do I convert from '_io.BytesIO' to a bytes-like object?</p>