Skip to content

Commit 245b3f2

Browse files
committed
Ensure bytestring is bytes before checking for gzip header
Related error: TypeError: startswith first arg must be str or a tuple of str, not bytes
1 parent e5128ec commit 245b3f2

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)