[Python-3000] Should len() clip to sys.maxsize or raiseOverflowError?

Guido van Rossum guido at python.org
Wed Sep 3 18:15:14 CEST 2008


2008/9/3 Hagen Fürstenau <hagenf at coli.uni-saarland.de>:
>> That said, I would actually be okay with the status quo (which does
>> raise an OverflowError) as long as we commit to fixing this properly
>> in 2.7 / 3.1, by removing the range restriction (like we've done for
>> other int operations a long time ago).
>
> What should be done when __len__() returns a float? In Python 2.6 the
> behaviour depends on whether the class in new-style or not. (Old-style
> classes raise a TypeError, new-style classes truncate.) Is there any
> good reason for truncating?

That souds like a bug. IMO TypeError is the right response here.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list