Skip to content

Commit abdb8f9

Browse files
committed
Allow both text- and bytes-based file objects as input
Fix #442.
1 parent 37952cd commit abdb8f9

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
@@ -357,6 +357,8 @@ def __init__(self, **kwargs):
357357
self.url = url
358358
elif file_obj is not None:
359359
bytestring = file_obj.read()
360+
if isinstance(bytestring, str):
361+
bytestring = bytestring.encode()
360362
self.url = getattr(file_obj, 'name', None)
361363
if self.url == '<stdin>':
362364
self.url = None

0 commit comments

Comments
 (0)