[MERGE] Fix bencoding of bools, provide a bdecode_tuple function.
Andrew Bennetts
andrew at canonical.com
Wed Jan 7 02:24:15 GMT 2009
In the grand tradition of every other bencode.py implementation, here are
some custom changes to our version[1].
First, this fixes encoding of bools so that they are encoded like ints,
rather than coming out as “iTruee” on the wire, which is invalid. Most
other implementations of bencode.py seem to use essentially the same bug fix
for this.
Second, it adds a bdecode_tuple function, so that callers that want tuples
rather than lists (e.g. because they are decoding keys into a repository)
can do so directly, rather than writing code like “keys = tuple(tuple(key)
for key in keys)”. I've found this version convenient in the smart protocol
code.
The “bdecode” function still yields lists in its result, so any plugins
relying on the existing behaviour should be unaffected by the changes.
-Andrew.
[1] For laughs, look at all the forks of the same file that Google can find:
<http://www.google.com/codesearch?q=file:bencode.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bencode-tweak-3924.patch
Type: text/x-diff
Size: 10293 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20090107/c4f83133/attachment.bin
More information about the bazaar
mailing list