@@ -198,6 +198,7 @@ def _write(self, data):
198198 self .ofp .write (data )
199199
200200 def _writecrc (self ):
201+ ## self.crc = binascii.crc_hqx('\0\0', self.crc) # XXXX Should this be here??
201202 self .ofp .write (struct .pack ('h' , self .crc ))
202203 self .crc = 0
203204
@@ -257,9 +258,10 @@ def __init__(self, ifp):
257258 self .ifp = ifp
258259 self .eof = 0
259260
260- def read (self , wtd ):
261+ def read (self , totalwtd ):
261262 """Read at least wtd bytes (or until EOF)"""
262263 decdata = ''
264+ wtd = totalwtd
263265 #
264266 # The loop here is convoluted, since we don't really now how much
265267 # to decode: there may be newlines in the incoming data.
@@ -283,7 +285,7 @@ def read(self, wtd):
283285 raise Error , 'Premature EOF on binhex file'
284286 data = data + newdata
285287 decdata = decdata + decdatacur
286- wtd = wtd - len (decdata )
288+ wtd = totalwtd - len (decdata )
287289 if not decdata and not self .eof :
288290 raise Error , 'Premature EOF on binhex file'
289291 return decdata
@@ -367,11 +369,12 @@ def _read(self, len):
367369
368370 def _checkcrc (self ):
369371 filecrc = struct .unpack ('h' , self .ifp .read (2 ))[0 ] & 0xffff
372+ ## self.crc = binascii.crc_hqx('\0\0', self.crc) # XXXX Is this needed??
370373 self .crc = self .crc & 0xffff
371374 if DEBUG :
372375 print 'DBG CRC %x %x' % (self .crc , filecrc )
373- # if filecrc != self.crc:
374- # raise Error, 'CRC error, computed %x, read %x'%(self.crc, filecrc)
376+ if filecrc != self .crc :
377+ raise Error , 'CRC error, computed %x, read %x' % (self .crc , filecrc )
375378 self .crc = 0
376379
377380 def _readheader (self ):
0 commit comments