[issue16865] ctypes arrays >=2GB in length causes exception

David Heffernan report at bugs.python.org
Wed May 10 05:50:46 EDT 2017


David Heffernan added the comment:

I just ran into this issue. I'm trying to write code like this:

(ctypes.c_char*bufferLen).from_buffer(buffer)

where buffer is a bytearray. When bufferLen is greater than 2GB I fail foul of this code in _ctypes.c

    long length;
    ....
    length = PyLong_AsLongAndOverflow(length_attr, &overflow);
    if (overflow) {
        PyErr_SetString(PyExc_OverflowError,
                        "The '_length_' attribute is too large");
        Py_DECREF(length_attr);
        goto error;
    }

Surely this should not be forcing long on us. Can't it use PyLong_AsSsize_t or perhaps PyLong_AsLongLongAndOverflow?

----------
nosy: +David Heffernan

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


More information about the Python-bugs-list mailing list