[Python-3000-checkins] r57596 - python/branches/py3k/Lib/binhex.py

guido.van.rossum python-3000-checkins at python.org
Tue Aug 28 05:35:36 CEST 2007


Author: guido.van.rossum
Date: Tue Aug 28 05:35:35 2007
New Revision: 57596

Modified:
   python/branches/py3k/Lib/binhex.py
Log:
Make this work on Mac as well (where Type and Creator are bytes instead of str).


Modified: python/branches/py3k/Lib/binhex.py
==============================================================================
--- python/branches/py3k/Lib/binhex.py	(original)
+++ python/branches/py3k/Lib/binhex.py	Tue Aug 28 05:35:35 2007
@@ -192,7 +192,12 @@
         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)


More information about the Python-3000-checkins mailing list