[C++-sig] TypeError: No to_python (by-value) converter found for C++ type: class std::basic_ostream<char, struct std::char_traits<char> >

Jakub Zytka kubol at kormoran.net
Wed Sep 29 11:38:48 CEST 2010


 > I get this error:
 > *TypeError: No to_python (by-value) converter found for C++ type: class
 > std::basic_ostream<char,struct std::char_traits<char> >*
 >
 > This is the python function
 > *    def serialise(self, gameobj, file):
 >          if(gameobj in self.components):
 >              file.write("HEY", 3)*
 >
 > What's the problem here? Is is because the ostream argument is an reference?
The problem is you are trying to copy a noncopyable object:

>              return class_<std::ostream, bases<std::ios>,
> boost::noncopyable>("ostream", no_init)
ostream is noncopyable

>                  .def("write", write ,
> return_value_policy<copy_non_const_reference>())
but you define write to return copy (of ostream)



More information about the Cplusplus-sig mailing list