ElementTree vs cElementTree exception confusion
aaron.bentley at utoronto.ca
Fri Sep 22 03:48:38 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Marien Zwart wrote:
> There are some selftest tests that fail when using the bundled
> ElementTree instead of cElementTree. This happens because cElementTree
> raises SyntaxError on invalid xml while ElementTree raises ExpatError.
> The attached bundle fixes the test.
Thanks. I would really like to see this go into 0.11, because raising
UnexpectedInventoryFormat makes it safe to cache basis inventories.
Otherwise, there's a risk you'll get ExpatError raised if you encounter
a basis inventory that isn't XML-based.
It is important to handle unexpected formats gracefully, because the
basis inventory is only a cache, and we can always get the inventory
from the repo instead. That guarantee makes it safe to vary our basis
inventory format without changing our working tree format. I renamed
our basis file just so we could achieve that guarantee.
> Would it be ok for those two files to import
> xml_serializer to get the right exception to catch, or should
> xml_serializer be modified to always raise some exception from
> bzrlib.errors so that knit.py and text.py can catch that exception
- From examining those cases, I would say The Right Thing is for the
serializer to raise a bzrlib.errors exception when it can't parse the XML.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v18.104.22.168 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar