[Python-Dev] PyInt_AsSsize_t on x64 (original) (raw)
Armin Rigo arigo at tunes.org
Sat May 5 12:55:18 CEST 2007
- Previous message: [Python-Dev] PyInt_AsSsize_t on x64
- Next message: [Python-Dev] PyInt_AsSsize_t on x64
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Kristján,
On Thu, May 03, 2007 at 03:57:26PM +0000, Kristján Valur Jónsson wrote:
if (nb->nblong != 0) { io = (PyIntObject*) (*nb->nblong) (op); } else { io = (PyIntObject*) (*nb->nbint) (op); }
Now, how to fix this? Should the code in intobject.c catch the AttributeError, maybe, and continue to the nbint?
The problem is specific to old-style classes: in principle, only them have all slots non-null even if they don't really define the corresponding special methods. With anything else than old-style classes you don't get an AttributeError if a special method doesn't exist, which makes checking for AttributeError in PyInt_AsSsize_t() strange.
Given that the long vs int difference doesn't really make sense any more nowadays, I'd think it would be saner to change the nb_long slot of old-style instances instead of PyInt_AsSsize_t(). The logic would be that if the nb_long slot implementation finds no "long" attribute on the instance it tries with "int" instead.
A bientot,
Armin.
- Previous message: [Python-Dev] PyInt_AsSsize_t on x64
- Next message: [Python-Dev] PyInt_AsSsize_t on x64
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]