This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson, serhiy.storchaka
Date 2012-10-18.18:52:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1350586351.5.0.511768200474.issue16277@psf.upfronthosting.co.za>
In-reply-to
Content
> Undefined behavior (or may be just the wrong behavior), we obtain later, > when 
> converting in PyLong_AsVoidPtr() zero integer back to pointer. On
> platforms 
> where converting NULL to an integer doesn't give zero it's a bug.

So maybe the fix should be to special case zero in PyLong_AsVoidPtr, and turn 0L back into NULL there?

I think it's just too risky to change the current behaviour in 3.2 and 3.3, given the number of places that PyLong_FromVoidPtr is used.  Unlike you, I don't have confidence that there are no current or future platforms that don't map NULL to 0.  It might be reasonable to consider a change for 3.4.

> I mean using PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)
> ((Py_uintptr_t)p - (Py_uintptr_t)(void *)NULL)) instead ...

Okay, thanks for explaining.
History
Date User Action Args
2012-10-18 18:52:31mark.dickinsonsetrecipients: + mark.dickinson, serhiy.storchaka
2012-10-18 18:52:31mark.dickinsonsetmessageid: <1350586351.5.0.511768200474.issue16277@psf.upfronthosting.co.za>
2012-10-18 18:52:31mark.dickinsonlinkissue16277 messages
2012-10-18 18:52:31mark.dickinsoncreate