[issue21199] Python on 64-bit Windows uses signed 32-bit type for read length

STINNER Victor report at bugs.python.org
Wed Apr 16 07:53:51 CEST 2014


STINNER Victor added the comment:

On Windows, the type of the size parameter of read() is an unsigned int, not long nor size_t:
http://msdn.microsoft.com/en-us/library/1570wh78.aspx

FileIO.read() of Python 3 uses a size_t type but also:

#ifdef MS_WINDOWS
    if (size > INT_MAX)
        size = INT_MAX;
#endif
...
#ifdef MS_WINDOWS
        n = read(self->fd, ptr, (int)size);
#else
        n = read(self->fd, ptr, size);
#endif


Using a size_t to parse the Python parameter would avoid an OverflowError and the function would be more portable. But it would not permit to read more than 2 GB at once.

----------
nosy: +haypo

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21199>
_______________________________________


More information about the Python-bugs-list mailing list