PyObject_Length() returns a P_ssize_t, not an int. Use a Py_ssize_t to avoid overflow.
Attach a file by drag & drop or click to upload