homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Oren Milman, serhiy.storchaka, vstinner
Date 2017年03月17日.19:52:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1489780334.51.0.943711507872.issue29839@psf.upfronthosting.co.za>
In-reply-to
Content
For now len() raises ValueError if __len__() returns small negative integer and OverflowError if __len__() returns large negative integer. 
>>> class NegativeLen:
... def __len__(self):
... return -10
... 
>>> len(NegativeLen())
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ValueError: __len__() should return >= 0
>>> class HugeNegativeLen:
... def __len__(self):
... return -sys.maxsize-10
... 
>>> len(HugeNegativeLen())
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
OverflowError: cannot fit 'int' into an index-sized integer
Proposed patch makes it always raising ValueError.
History
Date User Action Args
2017年03月17日 19:52:14serhiy.storchakasetrecipients: + serhiy.storchaka, vstinner, Oren Milman
2017年03月17日 19:52:14serhiy.storchakasetmessageid: <1489780334.51.0.943711507872.issue29839@psf.upfronthosting.co.za>
2017年03月17日 19:52:14serhiy.storchakalinkissue29839 messages
2017年03月17日 19:52:14serhiy.storchakacreate

AltStyle によって変換されたページ (->オリジナル) /