[MERGE] Treat assert statements in our code as a hard error

Matt Nordhoff mnordhoff at mattnordhoff.com
Thu Apr 24 13:29:49 BST 2008


Martin Pool wrote:

<snip>

Not that I'm a reviewer, but...

> === modified file 'bzrlib/_dirstate_helpers_py.py'
> --- bzrlib/_dirstate_helpers_py.py	2007-10-09 03:35:33 +0000
> +++ bzrlib/_dirstate_helpers_py.py	2008-04-24 07:22:53 +0000
> @@ -200,7 +200,9 @@
>      fields = text.split('\0')
>      # Remove the last blank entry
>      trailing = fields.pop()
> -    assert trailing == ''
> +    if trailing != '':
> +        raise AssertionError("dirtstate line %r has trailing garbage: %r" 
> +            % (trailing,))

"dirtstate"? :-)

>      # consider turning fields into a tuple.
>  
>      # skip the first field which is the trailing null from the header.
> @@ -217,11 +219,12 @@

<snip>

> === modified file 'bzrlib/bundle/bundle_data.py'
> --- bzrlib/bundle/bundle_data.py	2007-09-25 08:14:12 +0000
> +++ bzrlib/bundle/bundle_data.py	2008-04-24 07:22:53 +0000

<snip>

> @@ -308,8 +308,10 @@
>          
>          rev = self.get_revision(revision_id)
>          rev_info = self.get_revision_info(revision_id)
> -        assert rev.revision_id == rev_info.revision_id
> -        assert rev.revision_id == revision_id
> +        if not (rev.revision_id == rev_info.revision_id):
> +            raise AssertionError()
> +        if not (rev.revision_id == revision_id):
> +            raise AssertionError()

You can use != here.

>          sha1 = self._testament_sha1(rev, inventory)
>          if sha1 != rev_info.sha1:
>              raise TestamentMismatch(rev.revision_id, rev_info.sha1, sha1)
> @@ -347,7 +349,6 @@

<snip>

> === modified file 'bzrlib/hashcache.py'
> --- bzrlib/hashcache.py	2007-02-26 01:06:36 +0000
> +++ bzrlib/hashcache.py	2008-04-24 07:22:53 +0000

Ok, I should've gone to sleep hours ago. Good night. :-)
-- 



More information about the bazaar mailing list