[Python-Dev] Fwd: [Python-checkins] r51236 - in python/trunk: Doc/api/abstract.tex Include/abstract.h Include/object.h Lib/test/test_index.py Misc/NEWS Modules/arraymodule.c Modules/mmapmodule.c Modules/operator.c Objects/abstract.c Objects/classobject.c Objects/
Travis E. Oliphant
oliphant.travis at ieee.org
Tue Aug 15 00:28:45 CEST 2006
Travis E. Oliphant wrote:
>
> The idea is that the __index__() method should return an exact int or
> exact long or this call will raise an error. The restriction is present
> to remove the possibility of infinite recursion (though I'm not sure
> where that would occur exactly).
>
I just realized that returning a sub-class of Int and/or Long would not
be a problem here. The recursion problem that I was guarding against
only arose when the possibility of returning any object with an
.__index__() method was suggested.
Therefore, I think these exact int or exact long checks can and should
be replaced with PyInt_Check() and PyLong_Check().
-Travis
More information about the Python-Dev
mailing list