[Python-Dev] PyInt_AsSsize_t on x64

Kristján Valur Jónsson kristjan at ccpgames.com
Thu May 3 17:57:26 CEST 2007

Hello there.
I'm working on getting the 64 bit build of the trunk pass the testsuite.
Here is one snag, that you could help me fix.

In test_getargs2(), there is at line 190: self.failUnlessEqual(99, getargs_n(Long()))
Now, the Long class has a __int__ method which returns 99L.

However, we run into trouble here:
      if ((nb = op->ob_type->tp_as_number) == NULL ||
          (nb->nb_int == NULL && nb->nb_long == 0)) {
            PyErr_SetString(PyExc_TypeError, "an integer is required");
            return -1;

      if (nb->nb_long != 0) {
            io = (PyIntObject*) (*nb->nb_long) (op);
      } else {
            io = (PyIntObject*) (*nb->nb_int) (op);

trouble here
The trouble is that nb->nb_long is non zero, but when called, it returns an attribute error, since __long__ is missing.
nb_long points to instance_long.

Now, how to fix this?  Should the code in intobject.c catch the AttributeError, maybe, and continue to the nb_int?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20070503/09a8f9ae/attachment.html 

More information about the Python-Dev mailing list