diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1995-10-03 14:41:15 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1995-10-03 14:41:15 (GMT) |
commit | 685e16d7d64a75a3703f25888d3f192ad5c25f70 (patch) | |
tree | c9316684a56513dcef9ff4b44ca26f57c1deaed4 /Lib/binhex.py | |
parent | 8150760e6eea6e2946c50bbba7b0a5b59e894a2a (diff) | |
download | cpython-685e16d7d64a75a3703f25888d3f192ad5c25f70.zip cpython-685e16d7d64a75a3703f25888d3f192ad5c25f70.tar.gz cpython-685e16d7d64a75a3703f25888d3f192ad5c25f70.tar.bz2 |
Fixed hexbin handling
Diffstat (limited to 'Lib/binhex.py')
-rw-r--r-- | Lib/binhex.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/binhex.py b/Lib/binhex.py index a7f906d..2f97a33 100644 --- a/Lib/binhex.py +++ b/Lib/binhex.py @@ -198,6 +198,7 @@ class BinHex: self.ofp.write(data) def _writecrc(self): +## self.crc = binascii.crc_hqx('\0\0', self.crc) # XXXX Should this be here?? self.ofp.write(struct.pack('h', self.crc)) self.crc = 0 @@ -257,9 +258,10 @@ class _Hqxdecoderengine: self.ifp = ifp self.eof = 0 - def read(self, wtd): + def read(self, totalwtd): """Read at least wtd bytes (or until EOF)""" decdata = '' + wtd = totalwtd # # The loop here is convoluted, since we don't really now how much # to decode: there may be newlines in the incoming data. @@ -283,7 +285,7 @@ class _Hqxdecoderengine: raise Error, 'Premature EOF on binhex file' data = data + newdata decdata = decdata + decdatacur - wtd = wtd - len(decdata) + wtd = totalwtd - len(decdata) if not decdata and not self.eof: raise Error, 'Premature EOF on binhex file' return decdata @@ -367,11 +369,12 @@ class HexBin: def _checkcrc(self): filecrc = struct.unpack('h', self.ifp.read(2))[0] & 0xffff +## self.crc = binascii.crc_hqx('\0\0', self.crc) # XXXX Is this needed?? self.crc = self.crc & 0xffff if DEBUG: print 'DBG CRC %x %x'%(self.crc, filecrc) - #if filecrc != self.crc: - # raise Error, 'CRC error, computed %x, read %x'%(self.crc, filecrc) + if filecrc != self.crc: + raise Error, 'CRC error, computed %x, read %x'%(self.crc, filecrc) self.crc = 0 def _readheader(self): |