Mark Dickinson added the comment:

> 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16277>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to