[issue12159] Integer Overflow in __len__

2020-01-12 Thread STINNER Victor
STINNER Victor added the comment: New changeset d7c7adde003ddca5cbe4fc47cf09464ab95a066e by Victor Stinner (Zac Hatfield-Dodds) in branch 'master': bpo-12159: Document sys.maxsize limit in len() function reference (GH-17934) https://github.com/python/cpython/commit/d7c7adde003ddca5cbe4fc47cf0

[issue12159] Integer Overflow in __len__

2020-01-10 Thread Zac Hatfield-Dodds
Change by Zac Hatfield-Dodds : -- pull_requests: +17339 pull_request: https://github.com/python/cpython/pull/17934 ___ Python tracker ___ __

[issue12159] Integer Overflow in __len__

2011-05-23 Thread STINNER Victor
STINNER Victor added the comment: len(obj) is implemented using PyObject_Size() which is stores the result into a Py_ssize_t, and so is limited to sys.maxsize (2**31-1 or 2**63-1). This implementation detail should be documented. -- nosy: +haypo __

[issue12159] Integer Overflow in __len__

2011-05-23 Thread Benjamin Peterson
Benjamin Peterson added the comment: Yep, len() has to return something less than sys.maxsize. -- nosy: +benjamin.peterson resolution: -> works for me status: open -> closed ___ Python tracker ___

[issue12159] Integer Overflow in __len__

2011-05-23 Thread Peter Fankhaenel
New submission from Peter Fankhaenel : 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 flawle