[Python-Dev] fileobj.read(float): warning or error?

Alex Martelli aleaxit at gmail.com
Tue Jul 22 07:22:38 CEST 2008


I thought that's what we had __index__ for -- reject arguments that
don't SMOOTHLY turn into integers when an integer is actually
required!

Alex


On Mon, Jul 21, 2008 at 10:01 PM, "Martin v. Löwis" <martin at v.loewis.de> wrote:
>> Well, the real problem is os.urandom(4.2) which goes to an unlimited loop:
>>
>>   while len(bytes) < n:
>>       bytes += read(_urandomfd, n - len(bytes))
>>
>> because read(0.2) works as read(0) :-/
>
> I can't quite accept that as a bug in the library. If you give invalid
> parameters, Python should not crash, but it may start to behave in a
> nonsensical way.
>
> Of course, it would be possible to move the conversion warning one layer
> up, into os.urandom; if the argument is float, raise a warning, and then
> truncate.
>
> Regards,
> Martin
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/aleaxit%40gmail.com
>


More information about the Python-Dev mailing list