diff --git a/src/converter/builtin_converters.cpp b/src/converter/builtin_converters.cpp index 48e740cb..a39be7e7 100644 --- a/src/converter/builtin_converters.cpp +++ b/src/converter/builtin_converters.cpp @@ -40,13 +40,16 @@ namespace // An lvalue conversion function which extracts a char const* from a // Python String. - // Cannot have this lvalue conversion in Python 3, instead, we have - // char_rvalue_from_python. #if PY_VERSION_HEX < 0x03000000 void* convert_to_cstring(PyObject* obj) { return PyString_Check(obj) ? PyString_AsString(obj) : 0; } +#else + void* convert_to_cstring(PyObject* obj) + { + return PyUnicode_Check(obj) ? _PyUnicode_AsString(obj) : 0; + } #endif // Given a target type and a SlotPolicy describing how to perform a @@ -537,10 +540,11 @@ void initialize_builtin_converters() #if PY_VERSION_HEX < 0x03000000 registry::insert(convert_to_cstring,type_id(),&converter::wrap_pytype<&PyString_Type>::get_pytype); #else + registry::insert(convert_to_cstring,type_id(),&converter::wrap_pytype<&PyUnicode_Type>::get_pytype); //TODO(bhy) This doesn't work because for const char* a lvalue converter is // always expected. (See select_extract in extract.hpp for detail) // So we should figure out a workaround. - slot_rvalue_from_python(); + //slot_rvalue_from_python(); #endif // Register by-value converters to std::string, std::wstring