This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: fix for 1067728: Better handling of float arguments to seek
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: churchr, loewis, orenti, titus
Priority: normal Keywords: patch

Created on 2004-11-17 01:28 by churchr, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fileobject.patch churchr, 2004-11-17 01:32 Patch against 2.3.4 to fix 1067728
file.diff loewis, 2006-11-12 10:56
Messages (8)
msg47293 - (view) Author: Robert Church (churchr) Date: 2004-11-17 01:28
Instead of converting all float arguments to ints, this
first attempts to 
convert the argument to a PyLong, and then the old
conversion code takes over.

The upshot is that the limit of floating point
arguments to seek() is raised from (2 ** 32) - 1 to
somewhere above (2 ** 62).

Perhaps a better way to handle this would be to not
accept floating point arguments to seek().
msg47294 - (view) Author: Titus Brown (titus) Date: 2004-12-19 09:37
Logged In: YES 
user_id=23486

The patch works against HEAD; updated for line numbers (there's a very 
similar set of line elsewhere in the file):

http://issola.caltech.edu/~t/transfer/patch-1067760-seek.diff

rhettinger thought the current behavior was reasonable (see bug 
1067728).  I'm not qualified to comment ;) but it seems odd that floats 
would have drastically different limits than longs.  This looks like a 
reasonable compromise IMO.
msg47295 - (view) Author: Titus Brown (titus) Date: 2004-12-19 09:38
Logged In: YES 
user_id=23486

Sorry, I should add: patch works against head on Linux RH 9.0 (and 
should work everywhere).  Behavior tested with a script.
msg47296 - (view) Author: Titus Brown (titus) Date: 2004-12-23 08:29
Logged In: YES 
user_id=23486

Bob Ippolito pointed out that nowadays float-->int conversion of
arguments is deprecated; a DeprecationWarning wasn't being raised 
because conversion was done manually in seek.  Patch to fix this
at

http://issola.caltech.edu/~t/transfer/patch-1067760-seekwarn.diff

Linux RH 9.0 works, regression tests run w/o problem.

The patch is against the current HEAD but can probably be backported w/
o a problem.
msg47297 - (view) Author: Titus Brown (titus) Date: 2004-12-29 08:00
Logged In: YES 
user_id=23486

Updated patch to check return value of PyErr_Warn in case 'python -W 
error'  is specified.  No other objections raised on python-dev...

revised patch still at
http://issola.caltech.edu/~t/transfer/patch-1067760-seekwarn.diff
msg47298 - (view) Author: Oren Tirosh (orenti) Date: 2005-03-29 19:07
Logged In: YES 
user_id=562624

The actual usable range of a float is 2**53, not 2**62.
Above this the resolution drops below 1 byte. It's enough
for some 9000 terabytes.
msg47299 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-11-12 10:56
Logged In: YES 
user_id=21627

I'm attaching a different fix, which uses the index API to
obtain the offset.
As a consequence, passing a float becomes an outright error.
msg47300 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-11-12 18:26
Logged In: YES 
user_id=21627

After discussion on python-dev, I committed r52738, which
raises a deprecation warning when a float is passed as seek
argument; the meaning of doing so remains unchanged. The
original patch is thus rejected.
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41184
2004-11-17 01:28:23churchrcreate