diff --git a/cairosvg/parser.py b/cairosvg/parser.py index 3399be90..18d8c2e6 100644 --- a/cairosvg/parser.py +++ b/cairosvg/parser.py @@ -387,6 +387,8 @@ def __init__(self, **kwargs): if not bytestring: bytestring = self.fetch_url( parse_url(self.url), 'image/svg+xml') + if isinstance(bytestring, str): + bytestring = bytestring.encode('utf-8') if bytestring.startswith(b'\x1f\x8b'): bytestring = gzip.decompress(bytestring) tree = ElementTree.fromstring(