Commit bfc7dff6 authored by Serhiy Storchaka's avatar Serhiy Storchaka Committed by GitHub

[2.7] bpo-15718: Document the upper bound constrain on the __len__ return value. (GH-1256). (#1261)

(cherry picked from commit 85157cd8)
parent 91e5ee59
......@@ -1891,6 +1891,14 @@ sequences, it should iterate through the values.
:meth:`__nonzero__` method and whose :meth:`__len__` method returns zero is
considered to be false in a Boolean context.
.. impl-detail::
In CPython, the length is required to be at most :attr:`sys.maxsize`.
If the length is larger than :attr:`!sys.maxsize` some features (such as
:func:`len`) may raise :exc:`OverflowError`. To prevent raising
:exc:`!OverflowError` by truth value testing, an object must define a
:meth:`__nonzero__` method.
.. method:: object.__getitem__(self, key)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment