Message102325
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! |
|
Date |
User |
Action |
Args |
2010-04-04 08:34:34 | mark.dickinson | set | recipients:
+ mark.dickinson, meador.inge |
2010-04-04 08:34:34 | mark.dickinson | set | messageid: <1270370074.54.0.299825522165.issue8300@psf.upfronthosting.co.za> |
2010-04-04 08:34:32 | mark.dickinson | link | issue8300 messages |
2010-04-04 08:34:31 | mark.dickinson | create | |
|