Note that there are some explanatory texts on larger screens.

plurals
  1. POPython gzip: is there a way to decompress from a string?
    text
    copied!<p>I've read this <a href="https://stackoverflow.com/questions/1313845/if-i-have-the-contents-of-a-zipfile-in-a-python-string-can-i-decompress-it-witho">SO post</a> around the problem to no avail.</p> <p>I am trying to decompress a .gz file coming from an URL.</p> <pre><code>url_file_handle=StringIO( gz_data ) gzip_file_handle=gzip.open(url_file_handle,"r") decompressed_data = gzip_file_handle.read() gzip_file_handle.close() </code></pre> <p>... but I get <em>TypeError: coercing to Unicode: need string or buffer, cStringIO.StringI found</em></p> <p>What's going on?</p> <pre><code>Traceback (most recent call last): File "/opt/google/google_appengine-1.2.5/google/appengine/tools/dev_appserver.py", line 2974, in _HandleRequest base_env_dict=env_dict) File "/opt/google/google_appengine-1.2.5/google/appengine/tools/dev_appserver.py", line 411, in Dispatch base_env_dict=base_env_dict) File "/opt/google/google_appengine-1.2.5/google/appengine/tools/dev_appserver.py", line 2243, in Dispatch self._module_dict) File "/opt/google/google_appengine-1.2.5/google/appengine/tools/dev_appserver.py", line 2161, in ExecuteCGI reset_modules = exec_script(handler_path, cgi_path, hook) File "/opt/google/google_appengine-1.2.5/google/appengine/tools/dev_appserver.py", line 2057, in ExecuteOrImportScript exec module_code in script_module.__dict__ File "/home/jldupont/workspace/jldupont/trunk/site/app/server/tasks/debian/repo_fetcher.py", line 36, in &lt;module&gt; main() File "/home/jldupont/workspace/jldupont/trunk/site/app/server/tasks/debian/repo_fetcher.py", line 30, in main gziph=gzip.open(fh,'r') File "/usr/lib/python2.5/gzip.py", line 49, in open return GzipFile(filename, mode, compresslevel) File "/usr/lib/python2.5/gzip.py", line 95, in __init__ fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb') TypeError: coercing to Unicode: need string or buffer, cStringIO.StringI found </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload