Trouble with on Win32?

Prabhu Ramachandran prabhu at
Sun Aug 15 20:54:16 CEST 2004


I noticed peculiar behavior under Python-2.3.4 under Win32.  When I
run something like this:

f = open('t.txt', 'wb')
f = open('t.txt', 'r')
pos = f.tell()
val =
assert val ==

I get an assertion error at this point.  Everything works fine if I
read the file with 'rb' instead of 'r'.  But I can almost swear that
this used to work earlier.  I suspect that this behavior arises due to
recent changes in fileobject.c (specifically, v2.187) where universal
newline support was removed.

Could someone please clarify if this is this a bug or not?  I would
like to think that using tell and seek should work reliably enough for
text files.

The reason this is important for me is that I've been generating text
files (with gay abandon) for MayaVi ( for three
years now.  I always open the file using 'r'/'w' and not 'rb'/'wb'.
Everything used to work fine.  It never mattered where and how exactly
the files were generated.  Now, I get strange errors since I can no
longer seek into these files reliably.  I could switch to using
'rb'/'wb' universally but all existing files will no longer work
without either requiring a fair bit of effort on my part or on the
part of users changing their saved files.  I am loathe to ask every
user to change all their files and change the newlines.



p.s. Please CC me in on replies.  I'm not tracking  Thanks.

More information about the Python-list mailing list