Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-02-09 15:03:43


----- Original Message -----
From: "Phlip" <pplumlee_at_[hidden]>
> What's happening is this line fails to detect the NULL as a None:
>
> if aOrgan == None: return

Tersely, because I'm short on time:

None != NULL

These are different beasts.
If you want to be able to return none, you could do something like this:

// untested!
boost::python::reference my_function_wrapper(<args>)
{
  boost::shared_ptr<X> result = my_function(<args>);
  if (result.get() != 0) {
     return boost::python::reference(boost::python::to_python(result));
  }
  else {
    Py_INCREF(Py_None);
    return boost::python::reference(Py_None);
  }
}

Maybe I should automatically convert null smart pointers to None and None to
null smart pointers. I never thought to do it. Opinions?

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk