Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

See also a meta-issue issue29833.

If use OverflowError as a sign of infinite iterator in __length_hint__, this 
should be documented as a legitimate use case for OverflowError.

itertools.repeat.__length_hint__() and reversed.__length_hint__() currently 
raise a TypeError for infinite iterator. reversed.__length_hint__() returns 
NotImplemented (which raises a TypeError when convert to a C integer). Both 
TypeError and NotImplemented are handled by the consumer of __length_hint__: in 
PyObject_LengthHint(). An OverflowError is treated as error.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33939>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to