On Sun, Jan 18, 2009 at 1:52 AM, Hin-Tak Leung hintak_leung@yahoo.co.uk wrote:
--- On Sat, 17/1/09, Luke Kenneth Casson Leighton lkcl@lkcl.net wrote:
but the behaviour of msvcrt wrt crlf is _definitely_
not right, as it
stands, and as a result it completely screws any
possibility for
running python.exe under wine. completely. you
can't have files that
you write to, that are different from when they are
read back.
ok .... this turns out to be a _really_ interesting edge-case :)
lkcl@gonzalez:~/src/python2.5-2.5.2$ ./python.exe Python 2.5.2 (r252:60911, Jan 16 2009, 22:06:34) [gcc-mingw32] on win32 Type "help", "copyright", "credits" or "license" for more information.
f = open("tst", "w") f.write("hell\n") f.write("back\n") f.close()
[80]+ Stopped ./python.exe lkcl@gonzalez:~/src/python2.5-2.5.2$ more tst hell back lkcl@gonzalez:~/src/python2.5-2.5.2$ % ./python.exe f = open("tst", "r")
x = f.readline(5) x
'hell\r' <------- wrongggggg
f.seek(0) f.readline()
'hell\n' <-------- ah _ha_. if you don't specify the length to be read....
f.seek(0) f.readline(4)
'hell'
f.readline()
'\n'
will raise this as a bug, now that there's a known test case for it.
But that's as much a problem as mingw, as wine, as usage of python...
no it isn't.
I am about to go back to fix a bug with ghostscript's ijs interface when compiled with non-MSVC: IJS is a binary protocol (for communicating with non-postscript printer drivers), but if you don't explicitly declare "wb" and "rb", and precise behavior - whether to do \n to \r\n translation - is dependent on both compilers (mingw, msvc, borland) and C runtime (wine or native windows). So if you want it to work correctly, you explicitly declare everything.
that _isn't_ the case here.
I think python supports a wb/rb argument to open()?
yes it does but that is not what is being tested, here.
It is probably your usage of python is wrong here.
no, it isn't.
the regression test test_file.py has succeeded for years under proprietary native win32 platforms using the proprietary msvc compiler to build python.exe and python2N.dll for win32 platforms.
this particular test is therefore about testing and ensuring that \r\n handling SPECIFICALLY in O_TEXT mode is correct.
it has nothing to do with O_BINARY mode.
l.