Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Trouble with on Win32?

Thread Tools

Trouble with on Win32?

Prabhu Ramachandran
Posts: n/a

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.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
i have no trouble to send , ihave trouble reciving mail --any ideas John Penney Computer Support 4 08-29-2006 08:45 PM
having trouble securing my wireless laptop FireBrick Wireless Networking 2 08-10-2004 12:37 PM
Trouble staying connected to wifi Michael Giroux Wireless Networking 1 08-03-2004 08:33 PM
Trouble connecting in public hot spots Andres Perez Wireless Networking 2 07-16-2004 06:47 PM
trouble with caching or caching the trouble Hypo ASP .Net 6 08-01-2003 07:11 AM