From 5f458c7cb556eb530ba09c1c46a9fbc895371f6e Mon Sep 17 00:00:00 2001
From: Jeremy Fee <jmfee@usgs.gov>
Date: Thu, 2 Feb 2017 09:22:21 -0700
Subject: [PATCH] Update Util.read_url to use BytesIO

---
 geomagio/Util.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/geomagio/Util.py b/geomagio/Util.py
index e53d25c2..a26ff8f9 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:
-- 
GitLab