[MERGE][Trivial] invalid version tuple attempt to raise AssertionError fails with TypeError
Mark Hammond
mhammond at skippinet.com.au
Sat Sep 20 03:36:02 BST 2008
This is fairly trivial, but bzrlib._format_version_tuple() raises an
unintended exception when passed an invalid version tuple (so I'm reusing
that function even though it has an underscore - sue me ;)
Currently, bzrlib behaves like this:
% python -c "from bzrlib import _format_version_tuple;print
_format_version_tuple((1,2,3,4,5))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "bzrlib\__init__.py", line 89, in _format_version_tuple
raise AssertionError("version_info %r not valid" % version_info)
TypeError: not all arguments converted during string formatting
It seems clear the code is attempting to raise an AssertionError, but as
version_info is a tuple, things get upset. The fix is trivial:
raise AssertionError("version_info %r not valid" % (version_info,))
which results in the expected error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "bzrlib\__init__.py", line 89, in _format_version_tuple
raise AssertionError("version_info %r not valid" % (version_info,))
AssertionError: version_info (1, 2, 3, 4, 5) not valid
I couldn't find any existing tests relating to version tuple formatting,
otherwise I would have added a test for this case.
Cheers,
Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bad-version-info.patch
Type: application/octet-stream
Size: 2153 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080920/84898636/attachment.obj
More information about the bazaar
mailing list