Index: Modules/_fileio.c =================================================================== --- Modules/_fileio.c (révision 70631) +++ Modules/_fileio.c (copie de travail) @@ -380,15 +380,15 @@ if (self->fd < 0) return err_closed(); if (self->seekable < 0) { - int ret; - Py_BEGIN_ALLOW_THREADS - ret = lseek(self->fd, 0, SEEK_CUR); - Py_END_ALLOW_THREADS - if (ret < 0) + PyObject *pos = portable_lseek(self->fd, NULL, SEEK_CUR); + if (pos == NULL) { + PyErr_Clear(); self->seekable = 0; - else + } else { + Py_DECREF(pos); self->seekable = 1; } + } return PyBool_FromLong((long) self->seekable); } Index: Lib/test/test_largefile.py =================================================================== --- Lib/test/test_largefile.py (révision 70631) +++ Lib/test/test_largefile.py (copie de travail) @@ -1,6 +1,7 @@ """Test largefile support on system where this makes sense. """ +import io import os import stat import sys @@ -132,6 +133,12 @@ self.assertEqual(len(f.read()), 1) # else wasn't truncated + def test_seekable(self): + for pos in (2**31-1, 2**31, 2**31+1): + with io.open(TESTFN, 'rb') as f: + f.seek(pos) + self.assert_(f.seekable()) + def test_main(): # On Windows and Mac OSX this test comsumes large resources; It # takes a long time to build the >2GB file and takes >2GB of disk @@ -163,6 +170,7 @@ suite.addTest(TestCase('test_osstat')) suite.addTest(TestCase('test_seek_read')) suite.addTest(TestCase('test_lseek')) + suite.addTest(TestCase('test_seekable')) with open(TESTFN, 'w') as f: if hasattr(f, 'truncate'): suite.addTest(TestCase('test_truncate'))