[Pyrex] pyrexc error: Python object cannot be converted to __mpz_struct (?)

Heiko Wundram heikowu at ceosg.de
Fri May 28 10:06:59 CEST 2004


Am Freitag, 28. Mai 2004 09:56 schrieb Paul Prescod:
> Precisely what problem are you running into?

I'm not exactly running into problems, but I recall that somewhere on the 
Python list I read that you shouldn't call any explicit type functions (such 
as PyInt_AsLong()) as long as you don't know if the type of the object really 
is the type you want it to be, but rather stick to PyObject_* (the generic 
functions), then call PyInt_Check(), and then access PyInt_*.

But, as I've now looked into the documentation, I was wrong. PyInt_AsLong() 
will check whether it is passed a PyObject* to an integer, and if not, 
generate an exception, PyInt_AS_LONG() will not (this is the case where you 
may not call it directly if you haven't checked the actual type before the 
call). I guess I just confused the two. Pyrex generates correct code, true.

Heiko.




More information about the Pyrex mailing list