Knit corruption message triggered by KeyboardInterrupt

Martin Pool martinpool at gmail.com
Wed Mar 14 09:11:33 GMT 2007


On 3/14/07, John Arbash Meinel <john at arbash-meinel.com> wrote:
> Well, the code in question is handling GzipErrors, as well as other errors.
>
> I would see at least IOError and OSError. However, I could also see just
> separately catching KeyboardInterrupt with the standard:

    def _parse_record_header(self, version_id, raw_data):
        """Parse a record header for consistency.

        :return: the header and the decompressor stream.
                 as (stream, header_record)
        """
        df = GzipFile(mode='rb', fileobj=StringIO(raw_data))
        try:
            rec = self._check_header(version_id, df.readline())
        except Exception, e:
            raise KnitCorrupt(self._filename,
                              "While reading {%s} got %s(%s)"
                              % (version_id, e.__class__.__name__, str(e)))
        return df, rec

If you're wanting to report on GZipErrors then the gzip file should be
opened inside the try block.

I think giving some context on what we were trying to read when we hit
the error could be good.

Actually in some cases, such as this, it's incorrect and alarming to
say there is knit corruption, we should just say "error reading knit"
and let people draw their own conclusions.

-- 
Martin



More information about the bazaar mailing list