diff options
author | Guido van Rossum <guido@python.org> | 2007-05-24 22:05:19 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-24 22:05:19 (GMT) |
commit | 34a042d301d6ab88645046a6dfa6c38265ca4b39 (patch) | |
tree | 07782e330c6223b8ad4d783dab2ad81ea9e10056 /Lib | |
parent | 5c2fab6e23f8254a4af2f2e34c41aae2c14fced0 (diff) | |
download | cpython-34a042d301d6ab88645046a6dfa6c38265ca4b39.zip cpython-34a042d301d6ab88645046a6dfa6c38265ca4b39.tar.gz cpython-34a042d301d6ab88645046a6dfa6c38265ca4b39.tar.bz2 |
This is the last time I fix binhex. If it breaks again it goes in the dustbin.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/binhex.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Lib/binhex.py b/Lib/binhex.py index 8e421c1..ac1cb18 100644 --- a/Lib/binhex.py +++ b/Lib/binhex.py @@ -53,7 +53,7 @@ try: finfo = FSSpec(name).FSpGetFInfo() dir, file = os.path.split(name) # XXX Get resource/data sizes - fp = open(name, 'rb') + fp = io.open(name, 'rb') fp.seek(0, 2) dlen = fp.tell() fp = openrf(name, '*rb') @@ -172,11 +172,11 @@ class BinHex: name, finfo, dlen, rlen = name_finfo_dlen_rlen if isinstance(ofp, basestring): ofname = ofp - ofp = open(ofname, 'w') + ofp = io.open(ofname, 'wb') if os.name == 'mac': fss = FSSpec(ofname) fss.SetCreatorType('BnHq', 'TEXT') - ofp.write('(This file must be converted with BinHex 4.0)\n\n:') + ofp.write(b'(This file must be converted with BinHex 4.0)\r\r:') hqxer = _Hqxcoderengine(ofp) self.ofp = _Rlecoderengine(hqxer) self.crc = 0 @@ -253,7 +253,7 @@ def binhex(inp, out): finfo = getfileinfo(inp) ofp = BinHex(finfo, out) - ifp = open(inp, 'rb') + ifp = io.open(inp, 'rb') # XXXX Do textfile translation on non-mac systems while 1: d = ifp.read(128000) @@ -371,7 +371,7 @@ class _Rledecoderengine: class HexBin: def __init__(self, ifp): if isinstance(ifp, basestring): - ifp = open(ifp) + ifp = io.open(ifp, 'rb') # # Find initial colon. # @@ -381,12 +381,10 @@ class HexBin: raise Error, "No binhex data found" # Cater for \r\n terminated lines (which show up as \n\r, hence # all lines start with \r) - if ch == '\r': + if ch == b'\r': continue - if ch == ':': + if ch == b':': break - if ch != '\n': - dummy = ifp.readline() hqxifp = _Hqxdecoderengine(ifp) self.ifp = _Rledecoderengine(hqxifp) @@ -480,7 +478,7 @@ def hexbin(inp, out): ofss = FSSpec(out) out = ofss.as_pathname() - ofp = open(out, 'wb') + ofp = io.open(out, 'wb') # XXXX Do translation on non-mac systems while 1: d = ifp.read(128000) |