~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tuned_gzip.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-05-08 07:05:00 UTC
  • mfrom: (3376.2.15 no-asserts)
  • Revision ID: pqm@pqm.ubuntu.com-20080508070500-9zyyvsk0eev20t4w
(mbp) remove and disallow assert statements

Show diffs side-by-side

added added

removed removed

Lines of Context:
149
149
 
150
150
        if buf == "":
151
151
            self._add_read_data(self.decompress.flush())
152
 
            assert len(self.decompress.unused_data) >= 8, "what does flush do?"
 
152
            if len(self.decompress.unused_data) < 8:
 
153
                raise AssertionError("what does flush do?")
153
154
            self._gzip_tail = self.decompress.unused_data[0:8]
154
155
            self._read_eof()
155
156
            # tell the driving read() call we have stuffed all the data
175
176
                self._gzip_tail = self.decompress.unused_data[0:8]
176
177
            elif seek_length < 0:
177
178
                # we haven't read enough to check the checksum.
178
 
                assert -8 < seek_length, "too great a seek."
 
179
                if not (-8 < seek_length):
 
180
                    raise AssertionError("too great a seek")
179
181
                buf = self.fileobj.read(-seek_length)
180
182
                self._gzip_tail = self.decompress.unused_data + buf
181
183
            else:
200
202
        # We then check the that the computed CRC and size of the
201
203
        # uncompressed data matches the stored values.  Note that the size
202
204
        # stored is the true file size mod 2**32.
203
 
        assert len(self._gzip_tail) == 8, "gzip trailer is incorrect length."
 
205
        if not (len(self._gzip_tail) == 8):
 
206
            raise AssertionError("gzip trailer is incorrect length.")
204
207
        crc32, isize = struct.unpack("<LL", self._gzip_tail)
205
208
        # note that isize is unsigned - it can exceed 2GB
206
209
        if crc32 != U32(self.crc):