Mark Dickinson <dicki...@gmail.com> added the comment: 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! ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8300> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com