From fd602341df53fc2c5c3f90554a432a8ba3984320 Mon Sep 17 00:00:00 2001 From: Ryan May Date: Wed, 1 Nov 2017 15:36:06 -0600 Subject: [PATCH] MNT: Fix unicode issues on Python 2.7 Pass the raw response content, rather than decoded text, to the element tree parser. This allows the parser to detect the encoding using the standard xml tags. --- siphon/catalog.py | 2 +- siphon/radarserver.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/siphon/catalog.py b/siphon/catalog.py index b00301630..fad2388fe 100644 --- a/siphon/catalog.py +++ b/siphon/catalog.py @@ -186,7 +186,7 @@ def __init__(self, catalog_url): resp.raise_for_status() # begin parsing the xml doc - root = ET.fromstring(resp.text) + root = ET.fromstring(resp.content) self.catalog_name = root.attrib.get('name', 'No name found') self.datasets = DatasetCollection() diff --git a/siphon/radarserver.py b/siphon/radarserver.py index 4bce94772..35616d469 100644 --- a/siphon/radarserver.py +++ b/siphon/radarserver.py @@ -85,7 +85,7 @@ def _get_metadata(self): def _get_stations(self, station_file='stations.xml'): resp = self.get_path(station_file) - self.stations = parse_station_table(ET.fromstring(resp.text)) + self.stations = parse_station_table(ET.fromstring(resp.content)) def query(self): """Return a new query for the radar server.