Message49589
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).
|
|
Date |
User |
Action |
Args |
2007-08-23 15:46:00 | admin | link | issue1436368 messages |
2007-08-23 15:46:00 | admin | create | |
|