string formatter %x and a class instance with __int__ cannot handle long

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Jun 22 04:52:20 EDT 2007


En Thu, 21 Jun 2007 05:36:42 -0300, Kenji Noguchi <tokyo246 at gmail.com>  
escribió:

> I confirmed that "%08x" % int(y) works. And yes, I'm hoping so.
> It actually works that way if the v is less than or equal to 0x7ffffffff.
>
>> It is a bug, at least for me, and I have half of a patch addressing it.  
>> As a workaround, convert explicitely to long before formatting.
>
> I'm interested in your patch.  What's the other half still missing?

As you have seen, PyString_Format doesn't handle well objects that can be  
converted to long but are not longs themselves; I've modified that  
function, but PyUnicode_Format has a similar problem, that's "the other  
half".
Maybe this weekend I'll clean those things and submit the patch.

-- 
Gabriel Genellina




More information about the Python-list mailing list