Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

Am going to close this one because I don't see any straight-forward way around 
it and because it's technically not a bug (just an undesirable design 
artifact).  The use of TypeError for objects that don't define __len__ is 
deeply ingrained into Python (20 years).  If something inside a __len__ method 
raises a TypeError, it would be challenging to distinguish that from a missing 
__len__ method.  

[terry]
It might be possible to create internal subclasses of TypeError, AttributeError 
and whatnot, but that is a deep change with unknown implications for users, for 
other python implementations, for performance, for third-party modules, etc.  
It would need a PEP and is likely to get rejected on a cost-benefit basis -- 
the substantial API churn wouldn't be worth the microscopic benefit (i.e. most 
people never encounter this or care about it).

[benjamin]
The __length_hint__ protocol is a public API, so anyone can use it.  Also, the 
issue is a broader than __length_hint__, it is really distinguishing multiple 
possible meanings for a TypeError raised by a call to __len__.

----------
resolution:  -> invalid
status: open -> closed

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

Reply via email to