[issue29839] Avoid raising OverflowError in len() when __len__() returns negative large value

2017-04-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > The doc does not specify that 'length' cannot be non-negative. It does. https://docs.python.org/3/reference/datamodel.html#object.__len__ .. method:: object.__len__(self) Called to implement the built-in function :func:`len`. Should return the length

[issue29839] Avoid raising OverflowError in len() when __len__() returns negative large value

2017-04-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset baf9f29811dba9c06e76b8e220bd77260202f299 by Serhiy Storchaka in branch 'master': bpo-29839: Raise ValueError rather than OverflowError in len() for negative values. (#701) https://github.com/python/cpython/commit/baf9f29811dba9c06e76b8e220bd772

[issue29839] Avoid raising OverflowError in len() when __len__() returns negative large value

2017-04-07 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue29839] Avoid raising OverflowError in len() when __len__() returns negative large value

2017-03-24 Thread Terry J. Reedy
Terry J. Reedy added the comment: https://docs.python.org/3/library/functions.html#len * does not specify the exception. In such cases, we occasionally change exception in x.y.0 releases without prior notice other than News and What's New. Also, I think unnecessarily exposing a compile-switc

[issue29839] Avoid raising OverflowError in len() when __len__() returns negative large value

2017-03-17 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: I was going to say that this is an API change, but given that without this, folks would have to catch both exceptions and now only have to catch one of them, it isn't. -- nosy: +barry ___ Python tracker

[issue29839] Avoid raising OverflowError in len() when __len__() returns negative large value

2017-03-17 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- pull_requests: +575 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue29839] Avoid raising OverflowError in len() when __len__() returns negative large value

2017-03-17 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: 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