This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Kuberan.Naganathan, jcea, neologix, pitrou, vstinner
Date 2013-06-06.20:32:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1370550745.76.0.339032548742.issue12545@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-06-06 20:32:25vstinnersetrecipients: + vstinner, jcea, pitrou, neologix, Kuberan.Naganathan
2013-06-06 20:32:25vstinnersetmessageid: <1370550745.76.0.339032548742.issue12545@psf.upfronthosting.co.za>
2013-06-06 20:32:25vstinnerlinkissue12545 messages
2013-06-06 20:32:25vstinnercreate