[MERGE] don't report malformed bundles as NotABundle

Aaron Bentley aaron.bentley at utoronto.ca
Wed Jun 21 18:29:40 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Arbash Meinel wrote:
> Aaron Bentley wrote:
>>If we say 'assertRaises', it's a failure if it doesn't raise.

> But assertNotRaises could raise an IOError, or BadBundle, or IndexError,
> or KeyError, or anything.

If, in normal use, crlf bundles caused IOError, or IndexError, or
KeyError, that would be a normal kind of bug.  Raising NotABundle,
specifically, will cause very very confusing behaviour.  Nothing else
will cause that.

> If you want it to succeed, then just perform the action and don't
> assertRaises().

I want it to either succed or else not raise NotABundle.  I don't want
to codify that crlf bundles should raise BadBundle, but I can't assert
that they don't fail.

> I agree that bundles should support \r\n as much as they support \n. In
> the loop to find the header of the bundle, we are currently doing:

That doesn't look like the loop in bundle/serializer/__init__.py to me.
 Those lines are gone now.

> And then in '_read_next_entry()' we can change this line:
> line = line[1:-1].decode('utf-8') # Remove the '#' and '\n'
> to
> line = line[1:].rstrip().decode('utf-8')

I don't think so.  We may have trailing whitespace in our text, e.g.:

# message:
#   This is a message with a lot of
#   whitespace in it.

> The other piece is that I was originally planning on changing from a
> custom serializer to using RIO to read/write the information, and just
> wrap around the RIO iterator so that we prepend/strip the '# ' for each
> line.

Sure.  With the refactoring done, you certainly have the option of doing
that.  I think this format is nicer to read than RIO, though.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEmYIE0F+nu1YWqI0RAoo+AKCAC5mF08K+3VKsXb5UH0FsqIklYACfVMtI
yYJZlIS/Kef/C7MyltFLrF8=
=8O4v
-----END PGP SIGNATURE-----




More information about the bazaar mailing list