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

Nick Coghlan ncoghlan at gmail.com
Wed Sep 3 00:01:19 CEST 2008


Dj Gilcrease wrote:
> why would it raise an index error when log_entries has more indicies
> then sys.maxsize, it should just check the entry @ sys.maxsize.
> 
> Maybe I missed it, but why cant len just return an int, which if I
> remember correctly is now a long in py3k, so on a 64 bit system len
> would (hopefully) never lie, but on a 32 bit system it could return a
> number segnificently lower then the actual number of entries.

That's the implementation detail Guido is referring to - when len(obj)
delegates to obj.__len__(), the result of the method call gets stored in
a PySsize_t value, creating the problem.

It's fixable, but not for the current release cycle.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
            http://www.boredomandlaziness.org


More information about the Python-3000 mailing list