Index: Modules/bz2module.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/bz2module.c,v retrieving revision 1.24 diff -u -p -r1.24 bz2module.c --- Modules/bz2module.c 3 Jun 2005 19:47:00 -0000 1.24 +++ Modules/bz2module.c 10 Jun 2005 11:43:46 -0000 @@ -22,6 +22,18 @@ static char __author__[] = Gustavo Niemeyer \n\ "; +/* Our very own off_t-like type, 64-bit if possible */ +/* copied from Objects/fileobject.c */ +#if !defined(HAVE_LARGEFILE_SUPPORT) +typedef off_t Py_off_t; +#elif SIZEOF_OFF_T >= 8 +typedef off_t Py_off_t; +#elif SIZEOF_FPOS_T >= 8 +typedef fpos_t Py_off_t; +#else +#error "Large file support, but neither off_t nor fpos_t is large enough." +#endif + #define BUF(v) PyString_AS_STRING((PyStringObject *)v) #define MODE_CLOSED 0 @@ -962,7 +974,8 @@ static PyObject * BZ2File_seek(BZ2FileObject *self, PyObject *args) { int where = 0; - long offset; + PyObject *offobj; + Py_off_t offset; char small_buffer[SMALLCHUNK]; char *buffer = small_buffer; size_t buffersize = SMALLCHUNK; @@ -973,7 +986,15 @@ BZ2File_seek(BZ2FileObject *self, PyObje int rewind = 0; PyObject *ret = NULL; - if (!PyArg_ParseTuple(args, "l|i:seek", &offset, &where)) + if (!PyArg_ParseTuple(args, "O|i:seek", &offobj, &where)) + return NULL; +#if !defined(HAVE_LARGEFILE_SUPPORT) + offset = PyInt_AsLong(offobj); +#else + offset = PyLong_Check(offobj) ? + PyLong_AsLongLong(offobj) : PyInt_AsLong(offobj); +#endif + if (PyErr_Occurred()) return NULL; ACQUIRE_LOCK(self);