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 teoliphant
Recipients
Date 2006-03-07.15:48:36
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: YES 
user_id=5296

Guido is right. 

The wrap_index function should probably contain a check for
Int or Long before checking for overflow.  Otherwise, it
would be possible to define a type in C that when it returns
PY_SSIZE_T_MAX for the nb_index method it's __index__() call
from Python will return itself (i.e. a situation exists
where __index__() does not return an int or a long). 

I'm thinking:

if ((PyInt_Check(self) || PyLong_Check(self)) &&
    ((res == PY_SSIZE_T_MAX) || (res == -PY_SSIZE_T_MAX-1)) {
...
}

The reason this works is because the nb_index method returns
PY_SSIZE_T_MAX or -PY_SSIZE_T_MAX-1 on overflow (without
setting an error).  We just check for those cases and return
self if they show up because it might be an overflow
condition.  Even if it isn't an overflow, it will still be
fine because self is either PY_SSIZE_T_MAX or
-PY_SSIZE_T_MAX-1 so returning self will be the same integer
as PyInt_FromSsize_t will return (except it could be a long
integer instead of an integer). 


History
Date User Action Args
2007-08-23 15:46:00adminlinkissue1436368 messages
2007-08-23 15:46:00admincreate