Boost logo

Boost :

From: Andreas Dietrich (quasi_at_[hidden])
Date: 2001-08-17 13:52:16


On Fri, Aug 17, 2001 at 11:31:12AM -0400, David Abrahams wrote:
> Well, I don't think this is too hard to figure out, even for the
> uninitiated. Just look at
> /home/dada/boost_1_23_0/boost/python/conversions.hpp:327, as indicated
> below. My theory is borne out:
>
> inline PyObject* to_python(PyObject* p)
> {
> Py_INCREF(p); <<<<<<<<<<<<
> return p;
> }

Ok. You are right ;-) I was confused, because I was pretty sure
that it crashed before test even got called. Here is why:

#include <Python.h>
#include <stdexcept>
namespace {
 
   PyObject *test(int l,int h){
      throw std::runtime_error("hello");
      return 0;
   }
}
#include <boost/python/class_builder.hpp>
namespace python = boost::python;
BOOST_PYTHON_MODULE_INIT(crash) {
  try {
    python::module_builder this_module("crash");
    this_module.def(test,"test");
  }
  catch(...) {
    python::handle_exception();
  }
}

This snippet also leads to a segfault, unfortunately a different one:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 8469)]
0x40254753 in __sjpopnthrow () from /usr/lib/libstdc++-libc6.2-2.so.3

So it looks like my compiler is broken :-(. I still think the orignal code
should not seg-fault, but return None to python, but this should be trivial
to add.

Andreas

-- 
"We've heard that a million monkeys at a million keyboards could produce the
complete works of Shakespeare. Now, thanks to the Internet, we know this is not
true."  -- Robert Wilensky

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