diff --git a/geomagio/Util.py b/geomagio/Util.py index e53d25c25cf793037bbe40935e2bb39f404f41b2..a26ff8f947069323e48159e762775b77848f339a 100644 --- a/geomagio/Util.py +++ b/geomagio/Util.py @@ -2,7 +2,7 @@ import pycurl import numpy import os from obspy.core import Stats, Trace -from io import StringIO +from io import BytesIO class ObjectView(object): @@ -161,7 +161,7 @@ def read_url(url, connect_timeout=15, max_redirects=5, timeout=300): except Exception: pass content = None - out = StringIO() + out = BytesIO() curl = pycurl.Curl() try: curl.setopt(pycurl.FOLLOWLOCATION, 1) @@ -173,6 +173,7 @@ def read_url(url, connect_timeout=15, max_redirects=5, timeout=300): curl.setopt(pycurl.WRITEFUNCTION, out.write) curl.perform() content = out.getvalue() + content = content.decode('utf-8') except pycurl.error as e: raise IOError(e.args) finally: