[C++-sig] boost::python: wrap std::string?

Jonathan Brandmeyer jbrandmeyer at earthlink.net
Wed May 26 14:09:43 CEST 2004


On Wed, 2004-05-26 at 06:01, paul.bridger wrote:
> Okay, hopefully someone can tell me what I'm doing wrong here.
> I am trying to wrap a class that derives from std::string. Everything seems 
> to go just fine until I try to import the derived class in Python. This is 
> the error message I get:
> 
> RuntimeError: extension class wrapper for base class class 
> std::basic_string<char,struct std::char_traits<char>,class 
> std::allocator<char> > has not been created yet
> 
> What is my best course of action?

Boost.Python handles arguments and returns of std::string by converting
them to and from Python built-in strings rather than wrapping the
std::string interface.  So, how you handle this situation will depend on
your requirements for your class in Python.

HTH,
Jonathan Brandmeyer





More information about the Cplusplus-sig mailing list