logo       

Re: Null reference: msg#00149

programming.swig

Subject: Re: Null reference


On Nov 25, 2003, at 11:05 AM, <renz@xxxxxxxxxxxxxxxx> wrote:

Hello all,

I ran into a problem, but not sure whether it is a SWIG or Python problem.

This is a simplest class with operator == defined:

// v.h
class v
{
public:
v(const int a) : data(a) {}
bool operator==(const v& u) const {return data == u.data;}
int data;
};

% python
Python 2.2.2 (#1, Feb 10 2003, 00:23:53)
[GCC 3.2 20020903 (Red Hat Linux 8.0 3.2-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
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?

Could anyone help? Thanks.

I don't know the whole flow of control here, but that error message about "null reference"
is definitely coming from SWIG. It won't let you pass a NULL pointer to any function
taking a reference---since C++ doesn't allow references to be NULL.

-- Dave

_______________________________________________
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