[Python-Dev] Passing floats to file.seek

Fredrik Lundh fredrik at pythonware.com
Sun Nov 12 12:09:49 CET 2006


Martin v. Löwis wrote:
> Patch #1067760 deals with passing of float values to file.seek;
> the original version tries to fix the current implementation
> by converting floats to long long, rather than plain C long
> (thus supporting files larger than 2GiB).
>> I propose a different approach: passing floats to seek should
> be an error. My version of the patch uses the index API, this
> will automatically give an error.
>> Two questions:
> a) should floats be supported as parameters to file.seek

I don't really see why.
> b) if not, should Python 2.6 just deprecate such usage,
> or outright reject it?

Python 2.5 silently accepts (and truncates) a float that's within range, 
so a warning sounds like the right thing to do for 2.6. note that read 
already produces such a warning:
 >>> f = open("hello.txt")
 >>> f.seek(1.5)
 >>> f.read(1.5)
__main__:1: DeprecationWarning: integer argument expected, got float
'e'
</F>


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /