classification
Title: FileIO.seekable() can return False
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: pitrou, vstinner
Priority: normal Keywords: patch

Created on 2009-01-20 23:38 by pitrou, last changed 2010-09-10 23:22 by vstinner. This issue is now closed.

Files
File name Uploaded Description Edit
fileio_seekable-trunk-2.patch vstinner, 2009-03-27 01:21
Messages (9)
msg80295 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-01-20 23:38
FileIO.seekable() can return False if we first seek to a position such
that, when truncated to a signed int, it becomes negative:

>>> f = open('largefile', 'wb', buffering=0)
>>> f.seek(2**31, 0)
2147483648
>>> f.write(b'x')
1
>>> f.close()
>>> f = open('largefile', 'rb', buffering=0)
>>> f.seek(0, 2)
2147483649
>>> f.seekable()
False
msg80301 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-01-21 00:38
Patch with regression test in test_largefile: test 2**31-1, 2**31, 
2**31+1.
msg80302 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-01-21 00:40
See also issue #5008.
msg80474 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-01-24 19:37
Woops, I attached the wrong patch!
msg83545 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-03-13 23:47
Committed in r70352 (py3k), r70353 (3.0). Needs backport to trunk and
2.6, if someone is interested.
msg84238 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-03-27 00:42
> Needs backport to trunk and 2.6, if someone is interested.

I'm interrested by a backport at least in trunk. I updated the patch 
to trunk:
 - test directly _file._FileIO() instead of using open() because in 
Python trunk, a file has no seekable() method :-/
 - use contextlib.closing() because _FileIO doesn't implement context 
API (not __exit__() method)
msg84241 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-03-27 00:49
You can use io.open() instead of open()...
msg84246 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-03-27 01:21
> You can use io.open() instead of open()...

Alright, it's much easier with io.open() :-)
msg116059 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-09-10 23:22
It is fixed in 2.7 with the backport of the Python3's io library (r73394).
History
Date User Action Args
2010-09-10 23:22:08vstinnersetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg116059
2010-08-22 00:21:09georg.brandlsetversions: - Python 2.6
2009-03-27 01:21:40vstinnersetfiles: - fileio_seekable-trunk.patch
2009-03-27 01:21:33vstinnersetfiles: + fileio_seekable-trunk-2.patch

messages: + msg84246
2009-03-27 00:49:33pitrousetmessages: + msg84241
2009-03-27 00:42:59vstinnersetfiles: + fileio_seekable-trunk.patch

messages: + msg84238
2009-03-27 00:41:16vstinnersetfiles: - fileio_seekable.patch
2009-03-13 23:47:27pitrousetpriority: high -> normal
versions: - Python 3.0, Python 3.1
messages: + msg83545

resolution: accepted
stage: needs patch -> resolved
2009-01-24 19:37:37vstinnersetfiles: + fileio_seekable.patch
messages: + msg80474
2009-01-24 19:36:09vstinnersetfiles: - fileio_append.patch
2009-01-21 00:40:10vstinnersetmessages: + msg80302
2009-01-21 00:38:52vstinnersetfiles: + fileio_append.patch
keywords: + patch
messages: + msg80301
nosy: + vstinner
2009-01-20 23:57:39pitrousetpriority: high
stage: needs patch
2009-01-20 23:38:37pitroucreate