Message125530
Found it.
The file browser doesn't tell what line number it is, but in _io/Fileio.c function fileio_init, there is code like
#ifdef O_BINARY
flags |= O_BINARY;
#endif
#ifdef O_APPEND
if (append)
flags |= O_APPEND;
#endif
if (fd >= 0) {
if (check_fd(fd))
goto error;
self->fd = fd;
self->closefd = closefd;
}
Note that if O_BINARY is defined, it is set into the default flags for opening files by name. But if "opening" a file by fd, the fd is copied, regardless of whether it has O_BINARY set or not. The rest of the IO code no doubt assumes the file was opened in O_BINARY mode. But that isn't true of MSC std* handles by default.
How -u masks or overcomes this problem is not obvious, as yet, but the root bug seems to be the assumption in the above code. A setmode of O_BINARY should be done, probably #ifdef O_BINARY, when attaching a MS C fd to a Python IO stack. Otherwise it is going to have \r\r\n problems, it would seem.
Alternately, in the location where the Python IO stacks are attached to std* handles, those specific std* handles should have the setmode done there... other handles, if opened by Python, likely already have it done.
Documentation for open should mention, in the description of the file parameter, that on Windows, it is important to only attach Python IO stack to O_BINARY files, or beware the consequences of two independent newline handling algorithms being applied to the data stream... or to document that setmode O_BINARY will be performed on the handles passed to open. |
|
Date |
User |
Action |
Args |
2011-01-06 09:16:32 | v+python | set | recipients:
+ v+python, amaury.forgeotdarc, pitrou, brian.curtin |
2011-01-06 09:16:32 | v+python | set | messageid: <1294305392.18.0.431551244942.issue10841@psf.upfronthosting.co.za> |
2011-01-06 09:16:29 | v+python | link | issue10841 messages |
2011-01-06 09:16:29 | v+python | create | |
|