On 8/21/06, Alexander Belopolsky <[EMAIL PROTECTED]> wrote:
It should call PyInt_FromSize_t, without any casting. That will make it a PyLong if it's bigger than a Py_ssize_t, too.
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.
It should call PyInt_FromSize_t, without any casting. That will make it a PyLong if it's bigger than a Py_ssize_t, too.
Is there a simple automated way to detect situations like this? Maybe
there is a win64 compiler that would generate a warning.
I doubt it. Explicit casts are meant to silence warnings (among other things.) Warning for all casts is bound to generate quite a lot of warnings.
--
Thomas Wouters < [EMAIL PROTECTED]>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com