STINNER Victor added the comment: The patch is not complete: _iomodule.h defines PyLong_AsOff_t() and PyLong_FromOff_t(), but these functions don't support unsigned off_t (larger than 2^63-1).
#if defined(MS_WIN64) || defined(MS_WINDOWS) /* Windows uses long long for offsets */ typedef PY_LONG_LONG Py_off_t; # define PyLong_AsOff_t PyLong_AsLongLong # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */ # define PY_PRIdOFF "lld" /* format to use for that type */ #else /* Other platforms use off_t */ typedef off_t Py_off_t; #if (SIZEOF_OFF_T == SIZEOF_SIZE_T) # define PyLong_AsOff_t PyLong_AsSsize_t # define PyLong_FromOff_t PyLong_FromSsize_t # define PY_OFF_T_MAX PY_SSIZE_T_MAX # define PY_OFF_T_MIN PY_SSIZE_T_MIN # define PY_OFF_T_COMPAT Py_ssize_t # define PY_PRIdOFF "zd" #elif (HAVE_LONG_LONG && SIZEOF_OFF_T == SIZEOF_LONG_LONG) # define PyLong_AsOff_t PyLong_AsLongLong # define PyLong_FromOff_t PyLong_FromLongLong # define PY_OFF_T_MAX PY_LLONG_MAX # define PY_OFF_T_MIN PY_LLONG_MIN # define PY_OFF_T_COMPAT PY_LONG_LONG # define PY_PRIdOFF "lld" #elif (SIZEOF_OFF_T == SIZEOF_LONG) # define PyLong_AsOff_t PyLong_AsLong # define PyLong_FromOff_t PyLong_FromLong # define PY_OFF_T_MAX LONG_MAX # define PY_OFF_T_MIN LONG_MIN # define PY_OFF_T_COMPAT long # define PY_PRIdOFF "ld" #else # error off_t does not match either size_t, long, or long long! #endif #endif My patch fixes FileIO.seek(), but no BufferedReader & friends. So seek() works on open("/proc/self/mem", "rb", 0), but not on open("/proc/self/mem", "rb"). I didn't notice immediatly because I'm using an unbuffered file in my python-pytrace project. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue12545> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com