]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Make this work on Mac as well (where Type and Creator are bytes instead of str).
authorGuido van Rossum <guido@python.org>
Tue, 28 Aug 2007 03:35:35 +0000 (03:35 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 28 Aug 2007 03:35:35 +0000 (03:35 +0000)
Lib/binhex.py

index 0dfa475f4491385a24d9c689d9c28decd7479236..a56a8c85b1cff65767de268c0d1abbf7cd5dd129 100644 (file)
@@ -192,7 +192,12 @@ class BinHex:
         if nl > 63:
             raise Error, 'Filename too long'
         d = bytes([nl]) + name.encode("latin-1") + b'\0'
-        d2 = bytes(finfo.Type, "ascii") + bytes(finfo.Creator, "ascii")
+        tp, cr = finfo.Type, finfo.Creator
+        if isinstance(tp, str):
+            tp = tp.encode("latin-1")
+        if isinstance(cr, str):
+            cr = cr.encode("latin-1")
+        d2 = tp + cr
 
         # Force all structs to be packed with big-endian
         d3 = struct.pack('>h', finfo.Flags)