From: Guido van Rossum Date: Tue, 5 May 1998 22:21:35 +0000 (+0000) Subject: Ugly band-aid to work around a bug in Linux ftell(). X-Git-Tag: v1.5.2a1~756 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=91aaa92c888c8f1c026241d2306a01b6f2ecd1c5;p=thirdparty%2FPython%2Fcpython.git Ugly band-aid to work around a bug in Linux ftell(). --- diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 76f5318f51b5..d43f113ea8cf 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -421,7 +421,9 @@ new_buffersize(f, currentsize) struct stat st; if (fstat(fileno(f->f_fp), &st) == 0) { end = st.st_size; - pos = ftell(f->f_fp); + pos = lseek(fileno(f->f_fp), 0L, SEEK_CUR); + if (pos >= 0) + pos = ftell(f->f_fp); if (pos < 0) clearerr(f->f_fp); if (end > pos && pos >= 0)