Skip to content

Commit b4670ec

Browse files
authored
Merge pull request #443 from marcelometal/ensure-bytestring-type-before-gzip
Ensure bytestring is bytes before checking for gzip header
2 parents e5128ec + 245b3f2 commit b4670ec

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cairosvg/parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ def __init__(self, **kwargs):
387387
if not bytestring:
388388
bytestring = self.fetch_url(
389389
parse_url(self.url), 'image/svg+xml')
390+
if isinstance(bytestring, str):
391+
bytestring = bytestring.encode('utf-8')
390392
if bytestring.startswith(b'\x1f\x8b'):
391393
bytestring = gzip.decompress(bytestring)
392394
tree = ElementTree.fromstring(

0 commit comments

Comments
 (0)