[Pythonmac-SIG] file.read() after file.readline() problem
Jack Jansen
jack@oratrix.nl
Sat, 06 Oct 2001 00:33:49 +0200
First: thanks to all the people who did the tests on old Pythons. I
now know the bug was introduced between 1.5.2 and 2.0.
Recently, Alexandre Parenteau <alexp@strata.com> said:
> Jack,
>
> I think this is due to fileobject.c:526 :
>
> pos = lseek(fileno(f->f_fp), 0L, SEEK_CUR);
>
> If you replace that by :
>
> pos = fseek(f->f_fp, 0L, SEEK_CUR);
>
> It works.
Alexandre Holmes, thanks a lot! That looks like a very likely
candidate for the trouble spot.
But unfortunately your fix won't work, and the real problem must be
somewhere deeper down (in GUSI?).
The lseek() is intentional: as the comment above that code fragment
shows some stdio implementations flush the buffer on an fseek(), even
if the underlying file is unseekable (and fseek() should be a noop).
Moreover, this specific lseek() call is a no-op, so even though stdio
doesn't know about us doing it it should harm it either.
I have this very vague memory of problems with GUSI and seek() and it
messing up the GUSI buffering mechanism, but I think that that was a
long time ago. That 1.5.2 works fine also points that way (152 was
GUSI1 based, 2.0 was the first GUSI2 based MacPython. Also, the bug is
probably a general GUSI2 problem: 2.0 didn't use the hacked up
CarbonGUSI yet).
--
Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.cwi.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm