[New-bugs-announce] [issue12159] Integer Overflow in __len__

Peter Fankhaenel report at bugs.python.org
Mon May 23 16:24:02 CEST 2011

New submission from Peter Fankhaenel <pit007am at googlemail.com>:

An OverflowError is emitted in case the return value of __len__
exceeds 2**31-1.

The following code:

class C (object):
    def __len__ (self):
       return self.l

c = C()
c.l = 2**31

len (c)

# leads to an OverflowError in the last line. It works flawless for

c.__len__ ()

components: Windows
messages: 136644
nosy: peter.fankhaenel
priority: normal
severity: normal
status: open
title: Integer Overflow in __len__
versions: Python 2.6, Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list