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 Elvis.Pranskevichus
Recipients Elvis.Pranskevichus, amaury.forgeotdarc, benjamin.peterson, rhettinger, stutzbach, terry.reedy
Date 2011-04-01.23:29:12
SpamBayes Score 1.7192478e-07
Marked as misclassified No
Message-id <1301700553.56.0.722482281547.issue11674@psf.upfronthosting.co.za>
In-reply-to
Content
I guess, the best workaround would then be to use a decorator (or a metaclass) and wrap __len__ so that TypeError is caught and wrapped into some other exception.

On April 1, 2011 07:10:21 PM Benjamin Peterson wrote:
> What?? I certainly hope not. I thought it was supposed to be a performance
> hack.

__length_hint__ does indeed look like a hack and not a well-defined API.  It is also undocumented.
History
Date User Action Args
2011-04-01 23:29:13Elvis.Pranskevichussetrecipients: + Elvis.Pranskevichus, rhettinger, terry.reedy, amaury.forgeotdarc, benjamin.peterson, stutzbach
2011-04-01 23:29:13Elvis.Pranskevichussetmessageid: <1301700553.56.0.722482281547.issue11674@psf.upfronthosting.co.za>
2011-04-01 23:29:12Elvis.Pranskevichuslinkissue11674 messages
2011-04-01 23:29:12Elvis.Pranskevichuscreate