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.

作者 mark.dickinson
收信人 mark.dickinson, meador.inge
日期 2010-04-04.08:34:31
SpamBayes Score 1.2512917e-06
Marked as misclassified
Message-id <1270370074.54.0.299825522165.issue8300@psf.upfronthosting.co.za>
In-reply-to
内容
Probably both those conditions can't be satisfied;  I'm wasn't sure what happened if something's __index__ method returned something other than an int or long.

But now I bother to look at the source (in Objects/abstract.c) I see that there *is* already an explicit check for the result of nb_index being int or long (with TypeError being raised if the result isn't one of those).  Mea culpa.  I'll remove those lines (though I may leave an assert, just to be on the safe side).

The 2.x behaviour isn't ideal:  I'd prefer to just stop if the __index__ method is present and raises TypeError, rather than going on to check __int__ in that case.  But that presents problems with old-style classes, where PyIndex_Check is true even when no __index__ method is explicitly defined.

Thanks for the extra tests!
历史
日期 用户 动作 参数
2010-04-04 08:34:34mark.dickinson修改recipients: + mark.dickinson, meador.inge
2010-04-04 08:34:34mark.dickinson修改messageid: <1270370074.54.0.299825522165.issue8300@psf.upfronthosting.co.za>
2010-04-04 08:34:32mark.dickinson链接issue8300 messages
2010-04-04 08:34:31mark.dickinson创建