[pypy-issue] [issue1097] data loss in file.write()
hm
tracker at bugs.pypy.org
Mon Mar 26 01:41:56 CEST 2012
hm <hacman0 at gmail.com> added the comment:
The order of the output might be considered an implementation detail (although I'd argue that
it isn't), but whether output is recorded at all hardly seems an implementation detail. If
each works on its own (which is the case), they should be expected to work together. If the
flush of the write is delayed until garbage collection, then the seek of the file pointer for
proper "append" behavior should also be delayed. Otherwise, calling open(..., 'a') is behaving
like open(..., 'w'). That is the behavior I would call a bug. I can understand if this is not
an urgent item for you, as I know you are busy with other issues and making pypy even more
awesome, but I'd urge you to reconsider "wontfix." At least answer this, then I'll leave you
alone: if someone were to submit a patch modifying this behavior without breaking or slowing
anything else, would you reject it? I'm not offering at the moment, although I'd think about
looking into what it would take at least, but take it as a rhetorical question for now. jython, for instance, outputs all of the data, but out of order from how it is specified in the
code.
I read the further explanation at
http://pypy.readthedocs.org/en/latest/cpython_differences.html and I can see the point of view
there, but it seems wrong in the case of appends. The following C program, for instance,
outputs 234511111111111111111
#include <stdio.h>
int main()
{
char a1[] = "11111111111111111";
char a2[] = "2345";
FILE *f1 = fopen("bye", "a");
fwrite(a1, sizeof(a1[0]), sizeof(a1)-1, f1);
FILE *f2 = fopen("bye", "a");
fwrite(a2, sizeof(a2[0]), sizeof(a2)-1, f2);
fflush(f2);
}
Whether or not we agree on this particular issue, thanks for all the great work on the project!
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1097>
________________________________________
More information about the pypy-issue
mailing list