title: boost::python Export Custom Exception
body: <p>I am currently writing a C++ extension for Python using Boost.Python.  A function in this extension may generate an exception containing information about the error (beyond just a human-readable string describing what happened).  I was hoping I could export this exception to Python so I could catch it and do something with the extra information.</p>
  
  <p>For example:</p>
  
  <pre><code>import my_cpp_module
  try:
      my_cpp_module.my_cpp_function()
  except my_cpp_module.MyCPPException, e:
      print e.my_extra_data
  </code></pre>
  
  <p>Unfortunately Boost.Python seems to translate all C++ exceptions (that are subclasses of <code>std::exception</code>) into <code>RuntimeError</code>. I realize that Boost.Python allows one to implement custom exception translation however, one needs to use <code>PyErr_SetObject</code> which takes a <code>PyObject*</code> (for the exception's type) and a <code>PyObject*</code> (for the exception's value)--neither of which I know how to get from my Boost.Python classes.  Perhaps there is a way (which would be great) that I simply have not found yet.  Otherwise does anyone know how to export a custom C++ exception so that I may catch it in Python?</p>