[MERGE] BEncode Pyrex, pt 4

Andrew Bennetts andrew.bennetts at canonical.com
Wed May 27 21:47:02 BST 2009


Jelmer Vernooij wrote:
> Hi John,
> 
> This patch fixes;
> 
>  * Use PyInt_FromString rather than PyLong_FromString
>  * Avoid the use of strndup in the inner loop, instead using a static
> buffer that we copy into

This is not a complete review, but I'd also like to see tests for what
happens when encoding and decoding an extremely deeply nested structure.
e.g.:

    l = []
    for i in range(1000):
        l = [l]
    bencode.bencode(l)

And:

    s = 'l' * 1000 + 'e' * 1000
    bencode.bdecode(s)

I don't mind if they raise RuntimeError rather than successfully
encoding/decoding (I expect the current Python implementation does this),
but it would be a problem if either caused a segfault.

Be evil (when designing tests).  :)

-Andrew.




More information about the bazaar mailing list