title: boost-python pure virtual detecting missing implementation
body: <p>I have a C++ class with a pure virtual method exposed to python using boost-python. I am calling the virtual function from C++ and assuming the virtual function is implemented in python. It all works if the function is implemented but if it's not I get a nasty exception.</p>
  
  <p>I am trying to find a way to detect if the method is in fact implemented without calling when I load the class</p>
  
  <p>Roughly the code looks like this</p>
  
  <pre><code>#include &lt;boost/python.hpp&gt;
  
  using namespace boost::python;
  
  public Foo {
  public:
     void func() = 0;
  }
  
  class PyFoo : public Foo, public boost::python::wrapper&lt;Foo&gt; {
  public:
      void func() override {
          get_override("func")();
      }
  };
  
  BOOST_PYTHON_MODULE(example)
  {
      using namespace boost::python;
      class_&lt;PyFoo&gt;, boost::noncopyable&gt;("Foo")
          .def("func", pure_virtual(&amp;PyFoo::func))
          ;
  }
  
  void create {
      object main_module = import("__main__");
      object main_namespace = main_module.attr("__dict__");
  
      std::string overrideCommand(
      R"(
      import example
  
      class MyFoo(example.Foo):
          def __init__(self):
              example.Foo.__init__(self)
  
      # virtual function in C++. (Should be defined)
      #    def func(self):
      #        print('func called')
      )");
  
      boost::python::exec(overrideCommand.c_str(), main_namespace);
      result = eval("MyFoo()", main_namespace);
  
      // Can I detect if 'result' has func implemented? If I call it and it
      // is not defined death results. I have tried:
      object attr = result.attr("func");
  
      // but attr always seems to be set even if there is no function,
      // I think from the base class Foo.
  
      // This is the call:
      Foo&amp; t = extract&lt;Foo&amp;&gt;(result);
      t.func();
  }
  </code></pre>