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

Paul Prescod paul at prescod.net
Fri May 28 09:56:28 CEST 2004


Heiko Wundram wrote:
> 			_otherint = other

> Oh, and by the way, I've read that e.g. you shouldn't call PyInt_ToLong() 
> (which is how _otherint = other is resolved) before having checked the type 
> of the passed in python object.

I can't find an API named PyInt_ToLong. I think you mean PyInt_AsLong. 
But I can't find anything that suggests that it is wrong to call it with 
a non-long type. Furthermore, Pyrex seems to generate appropriate stack 
traces if I try to force a problem:

a = "abc"

def j(x):
     cdef int x1
     x1 = x
     print x1

j(a)

Traceback (most recent call last):
   File "/usr/bin/pyxrun", line 19, in ?
     pyximport.load_module(modname, filename)
   File "/Users/pprescod/data/code/pyximport/pyximport.py", line 141, in 
load_module
     mod = imp.load_dynamic(name, so_path)
   File "/Temporary Items/foo.pyx", line 8, in foo
     j(a)
   File "/Temporary Items/foo.pyx", line 5, in foo.j
     x1 = x

Precisely what problem are you running into?

  Paul Prescod





More information about the Pyrex mailing list