[Python-Dev] test warnings for "%x"%id(foo) on 2.3 branch

Martin v. Löwis martin at v.loewis.de
Tue Nov 4 16:51:49 EST 2003


Anthony Baxter <anthony at interlink.com.au> writes:

> I'm seeing a couple of warnings that I don't remember seeing at
> the time of the 2.3.2 release. Given what they are, it's possible
> that it's just a random thing (whether the id is < 0 or not).

What system is this on? I find it surprising that the id is < 0: on a
32-bit machine, this should only happen if you allocate more than 2GB.

> Anyone want to suggest an appropriate fix, or fix them? Otherwise I'll
> put it on the to-do list.

I'd reformulate them as 

"%x" % (id(o) & 0xffffffffL)

Of course, you have to replace 0xffffffffL with (unsigned)-1 of the
system (i.e. 2l*sys.maxint+1). I wonder whether creating a function

sys.unsigned(id(o))

would be appropriate, which returns its arguments for positive
numbers, and PyLong_FromUnsignedLong((unsigned)arg) otherwise.

Regards,
Martin




More information about the Python-Dev mailing list