Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b261df

Browse files
committed
Make this work on Mac as well (where Type and Creator are bytes instead of str).
1 parent 92bab81 commit 1b261df

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Lib/binhex.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ def _writeinfo(self, name, finfo):
192192
if nl > 63:
193193
raise Error, 'Filename too long'
194194
d = bytes([nl]) + name.encode("latin-1") + b'\0'
195-
d2 = bytes(finfo.Type, "ascii") + bytes(finfo.Creator, "ascii")
195+
tp, cr = finfo.Type, finfo.Creator
196+
if isinstance(tp, str):
197+
tp = tp.encode("latin-1")
198+
if isinstance(cr, str):
199+
cr = cr.encode("latin-1")
200+
d2 = tp + cr
196201

197202
# Force all structs to be packed with big-endian
198203
d3 = struct.pack('>h', finfo.Flags)

0 commit comments

Comments
 (0)