[New-bugs-announce] [issue16280] Inconsistency with PyLong_FromVoidPtr() and PyLong_AsVoidPtr()
Serhiy Storchaka
report at bugs.python.org
Thu Oct 18 22:36:45 CEST 2012
New submission from Serhiy Storchaka:
This issue is taken out of the discussion of issue16277.
PyLong_FromVoidPtr() has special case which maps null pointer to zero integer.
On platforms where (uintptr_t)(void *)0 is 0, this code has no effect and is redundant. But on hypothetic platforms where (uintptr_t)(void *)0 is not 0, PyLong_FromVoidPtr() maps NULL to 0 and then PyLong_AsVoidPtr() maps 0 to non-NULL. Also PyLong_FromVoidPtr() is multivalued, it maps to 0 NULL and may be some other pointer.
PyLong_FromVoidPtr() in 2.7 has special case only on platform where sizeof(void*) > sizeof(long). It commented as "optimize null pointers". In 3.x branch such optimization non needed because PyLong_FromUnsignedLongLong() already has special case for short integers.
The solution of this issue is getting rid of a special case, or adding a special case in PyLong_FromVoidPtr(). It is desirable to make it avoiding multivaluedity.
----------
components: Interpreter Core
messages: 173295
nosy: mark.dickinson, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Inconsistency with PyLong_FromVoidPtr() and PyLong_AsVoidPtr()
type: resource usage
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16280>
_______________________________________
More information about the New-bugs-announce
mailing list