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

2007-06-22 Thread Gabriel Genellina
En Thu, 21 Jun 2007 05:36:42 -0300, Kenji Noguchi <[EMAIL PROTECTED]> 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 0x7. > >> It is a bug, at least for me, and I have half of a patch addressing i

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

2007-06-21 Thread Kenji Noguchi
I looked at python2.5.1 source code. I noticed that, in Objects/stringobject.c around line 4684, long type is exceptionally handled, which is hack, and everything else falls to formatint. This explains why explicit converting to long before formatting fixes the problem. I made a patch but this is

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

2007-06-21 Thread Kenji Noguchi
2007/6/20, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > In your second example y is an instance of class X...not an int. y.v > is an int. Are you hoping it will cast it to an int as needed using > your method? If so, I think you need to do so explicitly...ie "%08x" > % int(y) > > ~Sean I confirmed