[pypy-dev] Fwd: [Python-Dev] print "%X" % id(object()) not so nice

Bob Ippolito bob at redivi.com
Fri Nov 19 23:06:10 CET 2004


Looks like I'm not the only one who has noticed this :)

Begin forwarded message:

> From: James Y Knight <foom at fuhm.net>
> Date: November 19, 2004 10:48:19 PM EET
> To: Python Dev <python-dev at python.org>
> Subject: [Python-Dev] print "%X" % id(object()) not so nice
>
> I think id() should never be returning a negative number. Both these 
> behaviors are poor:
>
> In 2.3:
> >>> print "%X" % id(o)
> __main__:1: FutureWarning: %u/%o/%x/%X of negative int will return a 
> signed string in Python 2.4 and up
> A5F48198
>
> In 2.4:
> >>> print "%X" %id(o)
> -5FC84D08
>
> Pointers are conventionally never treated or printed as signed. In 2.3 
> and before, it usually ended up okay, besides the warning, because 
> "%X" had broken behavior. In 2.4, now it's ending up doing the wrong 
> thing and printing a confusing value. I propose that id() always 
> return a positive value. This means that it will sometimes have to 
> return a long instead of an int, but, it already does that under some 
> circumstances on some architectures.
>
> Comments?
>
> James
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/bob%40redivi.com



More information about the Pypy-dev mailing list