title: How can I upcast a Python derived class to it's c++ base with Boost Python?
body: <p>I have a c++ class with a pure virtual function which I wrap in the following way using Boost Python:</p>
  
  <pre><code>class Model {
      virtual double Test() = 0;
  };
  class ModelWrapper : public Model, public boost::python::wrapper&lt;Model&gt; {
      double Test() {
          return this-&gt;get_override("Test")(); 
      }     
  };
  BOOST_PYTHON_MODULE(mymodule)
  {
      class_&lt;ModelWrapper, boost::noncopyable&gt;("Model")
          .def("Test, pure_virtual(&amp;Model::Test))
      ;
  }
  </code></pre>
  
  <p>I also have a c++ function that's expecting a Model object as an argument:</p>
  
  <pre><code>double MyFunction(Model&amp; m) { 
      return m.Test() 
  }
  </code></pre>
  
  <p>Now what I would like to do is to make a derived class in Python that overrides the Model::Test function but can still be passed to MyFunction. Something like this:</p>
  
  <pre><code>from mymodule import *
  
  class NewModel(Model):
      def Test(self):
          return 0.5
  
  m = NewModel()
  print(MyFunction(m))
  </code></pre>
  
  <p>which I would want to print out 0.5 in this case. Instead I get this error:</p>
  
  <pre><code>&gt; ArgumentError: Python argument types in
  &gt;     mymodule.MyFunction(NewModel) did not match C++ signature:
  &gt;     MyFunction(Model {lvalue})
  </code></pre>
  
  <p>I'm not sure what step I'm missing in order for NewModel to be usable where Model is expected. Any insight would be greatly appreciated.</p>