[Python-Dev] returning longs from hash() (original) (raw)
Armin Rigo arigo at tunes.org
Wed Aug 9 11:47:25 CEST 2006
- Previous message: [Python-Dev] returning longs from __hash__()
- Next message: [Python-Dev] returning longs from __hash__()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Martin,
On Tue, Aug 08, 2006 at 11:14:56PM +0200, "Martin v. L?wis" wrote:
- h = PyIntAsLong(res); + if (PyLongCheck(res)) + h = res->obtype->tphash(res);
This bug will keep showing up forever :-) It's unsafe against a user subclassing 'long' and overriding hash of that subclass to return the object itself -- it would cause an infinite C recursion.
Instead, we need either a new API like PyLong_Hash(), or call 'PyLong_Type.tp_hash(res)'.
Same in the other change.
A bientot,
Armin
- Previous message: [Python-Dev] returning longs from __hash__()
- Next message: [Python-Dev] returning longs from __hash__()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]