New submission from Erik Wennstrom <ewenn...@indiana.edu>:

Sometimes, when the position on a text file object is right before a line 
break, the file object method .tell() returns a bizarre large number 
(18446744073709551621) instead of the correct position.

The incorrect behavior occurs consistently for certain text files, but 
sometimes, a slight modification of the file will cause the behavior to revert 
to normal.

I can get this behavior in both Python 3.7.2 and 3.6.5. I've seen it on two 
different Windows X machines.

I've included two sample text files and a program that tests them both with the 
same code, which opens the file, reads 4 characters from the file, and then 
prints the result of the .tell() method. Both should print 4, but one of them 
prints 18446744073709551621. The only difference between the text files is that 
one of them has a single extra character before the last line break (which I 
should note is several lines away from the line where the weird behavior 
occurs).

Frankly, I don't even have a sliver of an inkling of a notion as to how this 
error might happen. I encountered it in the middle of teaching an intro 
programming lecture where I was showing them how file object positions work 
with .read(). Brought the entire class to a screeching halt.

----------
components: Windows
files: telltest.zip
messages: 337148
nosy: erwenn, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: file object method .tell() sometimes returns large number when position 
is right before a line break
type: behavior
versions: Python 3.6, Python 3.7
Added file: https://bugs.python.org/file48186/telltest.zip

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36190>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to