99 bp::extract<std::string> string_extractor{obj};
100 bp::extract<std::wstring> unicode_extractor{obj};
103 if (string_extractor.check()) {
104 str = string_extractor;
106 else if (unicode_extractor.check()) {
108 str = utf_to_utf<char>(unicode.
c_str(), unicode.
c_str() + unicode.
size());
111 std::string obj_type_name = bp::extract<std::string>(obj.attr(
"__class__").attr(
"__name__"));
112 PyErr_Format(PyExc_TypeError,
113 "SourceXtractor output wrapper only accepts classic strings or unicode strings, got %s",
114 obj_type_name.
c_str()
116 bp::throw_error_already_set();