[New-bugs-announce] [issue2723] Truncate __len__() at sys.maxsize

Alexander Belopolsky report at bugs.python.org
Wed Apr 30 06:36:32 CEST 2008

New submission from Alexander Belopolsky <belopolsky at users.sourceforge.net>:

On Tue, Apr 29, 2008 at 10:36 PM, Guido van Rossum <guido at python.org> 
>  Let's also fix __len__() so that it returns sys.{maxint,maxsize} when
>  the result doesn't fit in a Py_ssize_t.


With attached patch given

class x:
    def __len__(self):
        return 2**100

len(x()) and len(range(2**100)) will return sys.maxsize.

components: Interpreter Core
files: len.diff
keywords: patch
messages: 65989
nosy: belopolsky
severity: normal
status: open
title: Truncate __len__() at sys.maxsize
versions: Python 3.0
Added file: http://bugs.python.org/file10143/len.diff

Tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list