Re: [Python-Dev] A cast from Py_ssize_t to long

2006-08-21 Thread Thomas Wouters
On 8/21/06, Alexander Belopolsky <[EMAIL PROTECTED]> wrote: There are also cases of implicit casts like this  that were notcaught so far:static Py_ssize_tmmap_buffer_getreadbuf(mmap_object *self, Py_ssize_t index, constvoid **ptr){  ... return self->size; }static Py_ssize_tmmap_buffer_getwr

Re: [Python-Dev] A cast from Py_ssize_t to long

2006-08-21 Thread Alexander Belopolsky
On Aug 21, 2006, at 10:34 AM, Thomas Wouters wrote: > > 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

Re: [Python-Dev] A cast from Py_ssize_t to long

2006-08-21 Thread Thomas Wouters
On 8/21/06, Alexander Belopolsky <[EMAIL PROTECTED]> wrote: 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.

Re: [Python-Dev] A cast from Py_ssize_t to long

2006-08-21 Thread Alexander Belopolsky
On 8/21/06, Thomas Wouters <[EMAIL PROTECTED]> 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, PyO

Re: [Python-Dev] A cast from Py_ssize_t to long

2006-08-21 Thread Thomas Wouters
On 8/21/06, Alexander Belopolsky <[EMAIL PROTECTED]> wrote: On Aug 15, 2006, at 3:16 AM, Martin v. Löwis wrote:>> Where does it assume that it is safe to case ssize_t -> long?> That would be a bug.Is this a bug?file_readinto(PyFileObject *f, PyObject *args) {... Py_ssize_t ndone, nnow;...