This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pterk
Recipients
Date 2006-01-16.03:24:05
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=174455

I have done some additional research on this.

It appears the bug is in ftell of the windows c-library and
it seems to be a 'known problem'. See:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ftell.html

More here:
http://www.cygwin.com/faq/faq.api.html
http://gnuwin32.sourceforge.net/compile.html (search for
ftell in both cases)

Also see:

http://sourceforge.net/tracker/index.php?func=detail&aid=1381717&group_id=5470&atid=105470

So even though the file isn't opened with 'rt' I gather from
Tim Peter's remark about 't' on windows that the default is
't' anyway unless you really try. 

So this example is *exactly* what the matlab-people found.
That is nice to know I guess but it doesn't really help to
solve the problem.

It seems to me there are three solutions.

1. ftell could be fixed for unix-files on windows.* Not very
likely to happen soon. 
2. Python could special-case this for this specific
scenario. Way beyond my capabilities and probably too much
hassle in any case especially since the 'fix' is so easy
(just open with 'rb').
3. Leave it as is but document it. I have submitted a
(doc-)patch 1407021
(http://sourceforge.net/tracker/index.php?func=detail&aid=1407021&group_id=5470&atid=305470)
for the library reference (libstdtypes.tex) that reads:

Please note that tell() can return illegal values (after an
fgets()) on Windows when reading files with UNIX-style
line-endings. Use 'rb'-mode to circumvent this
problem.

* MS provides this note in the compatibility section of the
c-runtime libraries: "Note: In this version of Visual C++,
UNIX compatibility information has been removed from the
function descriptions."

In case your wondering what 'this version' is: VS.NET and VS
6.0. Apperantly there were no other 'previous versions'. 
History
Date User Action Args
2007-08-23 14:37:07adminlinkissue1396471 messages
2007-08-23 14:37:07admincreate