logo       

Re: Null reference: msg#00153

programming.swig

Subject: Re: Null reference

On 2003.11.25 12:05, renz@xxxxxxxxxxxxxxxx wrote:
I ran into a problem, but not sure whether it is a SWIG or Python
problem.

>>> import mod
>>> None in (mod.v(1), None)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "mod.py", line 38, in __eq__
def __eq__(*args): return apply(_mod.v___eq__,args)
TypeError: null reference

This error does not occur if operator == is not defined. Why == is
called here anyway?

I guess it's because
None in (mod.v(1), None)
is implemented as:
mod.v(1) == None or None == None
hence the call to __eq__. But as Dave said, you cannot pass it a null pointer (that's what None is translated into). You might have to rewrite the failing expression in order to avoid this.

Cheers,
Luigi
_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise