[Python-checkins] r50667 - in python/trunk: Lib/binhex.py Misc/NEWS
bob.ippolito
python-checkins at python.org
Sat Jul 15 18:53:17 CEST 2006
Author: bob.ippolito
Date: Sat Jul 15 18:53:15 2006
New Revision: 50667
Modified:
python/trunk/Lib/binhex.py
python/trunk/Misc/NEWS
Log:
Patch #1220874: Update the binhex module for Mach-O.
Modified: python/trunk/Lib/binhex.py
==============================================================================
--- python/trunk/Lib/binhex.py (original)
+++ python/trunk/Lib/binhex.py Sat Jul 15 18:53:15 2006
@@ -44,22 +44,14 @@
#
# Workarounds for non-mac machines.
-if os.name == 'mac':
- import macfs
- import MacOS
- try:
- openrf = MacOS.openrf
- except AttributeError:
- # Backward compatibility
- openrf = open
-
- def FInfo():
- return macfs.FInfo()
+try:
+ from Carbon.File import FSSpec, FInfo
+ from MacOS import openrf
def getfileinfo(name):
- finfo = macfs.FSSpec(name).GetFInfo()
+ finfo = FSSpec(name).FSpGetFInfo()
dir, file = os.path.split(name)
- # XXXX Get resource/data sizes
+ # XXX Get resource/data sizes
fp = open(name, 'rb')
fp.seek(0, 2)
dlen = fp.tell()
@@ -75,7 +67,7 @@
mode = '*' + mode[0]
return openrf(name, mode)
-else:
+except ImportError:
#
# Glue code for non-macintosh usage
#
@@ -183,7 +175,7 @@
ofname = ofp
ofp = open(ofname, 'w')
if os.name == 'mac':
- fss = macfs.FSSpec(ofname)
+ fss = FSSpec(ofname)
fss.SetCreatorType('BnHq', 'TEXT')
ofp.write('(This file must be converted with BinHex 4.0)\n\n:')
hqxer = _Hqxcoderengine(ofp)
@@ -486,7 +478,7 @@
if not out:
out = ifp.FName
if os.name == 'mac':
- ofss = macfs.FSSpec(out)
+ ofss = FSSpec(out)
out = ofss.as_pathname()
ofp = open(out, 'wb')
@@ -519,6 +511,7 @@
def _test():
if os.name == 'mac':
+ import macfs
fss, ok = macfs.PromptGetFile('File to convert:')
if not ok:
sys.exit(0)
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Sat Jul 15 18:53:15 2006
@@ -22,6 +22,8 @@
Library
-------
+- Patch #1220874: Update the binhex module for Mach-O.
+
Extension Modules
-----------------
More information about the Python-checkins
mailing list