[Python-Dev] A cast from Py_ssize_t to long
Alexander Belopolsky
alexander.belopolsky at gmail.com
Mon Aug 21 16:08:02 CEST 2006
On 8/21/06, Thomas Wouters <thomas at python.org> wrote:
[snip]
> > Is this a bug?
[snap]
> Yes. Py_ssize_t can be bigger than a long (on LLP64 systems, such as Win64).
Here is a similar problem:
typedef struct {
...
size_t pos;
...
} mmap_object;
...
mmap_tell_method(mmap_object *self, PyObject *unused)
{
CHECK_VALID(NULL);
return PyInt_FromLong((long) self->pos);
}
See Modules/mmapmodule.c .
Here a cast to ssize_t would, technically speaking, not be safe
either, but it may be worth using ssize_t anyways.
Is there a simple automated way to detect situations like this? Maybe
there is a win64 compiler that would generate a warning.
More information about the Python-Dev
mailing list