[pypy-issue] [issue1582] file.tell() has wrong position after failed seek with SEEK_CUR

Alex Gaynor tracker at bugs.pypy.org
Tue Aug 13 00:04:32 CEST 2013


New submission from Alex Gaynor <alex.gaynor at gmail.com>:

Alexanders-MacBook-Pro:openstack-swift alex_gaynor$ cat t.py
import os
from tempfile import TemporaryFile


with TemporaryFile('r+w') as f:
    f.write('123456789x12345678><123456789\n')
    f.write('1234><234\n')
    f.write('123456789x123456789\n')

    f.seek(0, os.SEEK_END)
    f.seek(-25, os.SEEK_CUR)
    f.read(25)
    f.seek(-25, os.SEEK_CUR)
    f.tell()
    f.seek(-25, os.SEEK_CUR)
    f.read(25)
    f.seek(-25, os.SEEK_CUR)
    f.tell()
    try:
        f.seek(-25, os.SEEK_CUR)
    except IOError:
        pass
    print f.tell()
Alexanders-MacBook-Pro:openstack-swift alex_gaynor$ python t.py
10
Alexanders-MacBook-Pro:openstack-swift alex_gaynor$ pypy t.py
60

----------
messages: 6055
nosy: agaynor, pypy-issue
priority: bug
status: unread
title: file.tell() has wrong position after failed seek with SEEK_CUR

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1582>
________________________________________


More information about the pypy-issue mailing list