[issue16273] f.tell() returning negative number on Windows build

Giacomo Alzetta report at bugs.python.org
Thu Apr 11 18:42:06 CEST 2013


Giacomo Alzetta added the comment:

I can reproduce a similar behaviour, but instead of negative values I obtain huge values(which may as well be a "negative" unsigned converted to a python int).

See this stackoverflow question: http://stackoverflow.com/questions/15934950/python-file-tell-giving-strange-numbers

If it doesn't use ftell() then this might mean that there is a new bug in the current implementation? I can reproduce the results of the questioner, on a windows7 machine with python3.3.0, with the following code:

    with open('C:/Users/Giacomo/test', 'wb') as f:
        f.write(b'hello\r\n\r\n-data1:blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\r\n\r\n\r\n-data2:blah blah blah blah blah blah blah blah blah blah blah\r\n-data3: Empty\r\n\r\n-data4: Empty')
    with open('C:/Users/Giacomo/test', 'rt') as f:
        for line in iter(f.readline, ''):
            print(f.tell())

Which outputs:

    7
    9
    18446744073709551714
    99
    101
    164
    179
    181
    194

As I explained in my answer I thought the 1844... was due to the "ftell() bug", but if that's not it I'm at a loss. Could you explain this results with the current implementation?

By the way: it seems to be a python3.3 bug, since python3.2.3 is not affected.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16273>
_______________________________________


More information about the Python-bugs-list mailing list