Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/converter/builtin_converters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,18 @@ namespace

// An lvalue conversion function which extracts a char const* from a
// Python String.
#if PY_VERSION_HEX < 0x03000000
void* convert_to_cstring(PyObject* obj)
{
#if PY_VERSION_HEX < 0x03000000
return PyString_Check(obj) ? PyString_AsString(obj) : 0;
}
#elif PY_VERSION_HEX < 0x03070000
void* convert_to_cstring(PyObject* obj)
{
return PyUnicode_Check(obj) ? _PyUnicode_AsString(obj) : 0;
}
#else
void* convert_to_cstring(PyObject* obj)
{
#elif PY_VERSION_HEX < 0x030E0000
return PyUnicode_Check(obj) ? const_cast<void*>(reinterpret_cast<const void*>(_PyUnicode_AsString(obj))) : 0;
}
#else
return PyUnicode_Check(obj) ? const_cast<void*>(reinterpret_cast<const void*>(PyUnicode_AsUTF8(obj))) : 0;
#endif
}

// Given a target type and a SlotPolicy describing how to perform a
// given conversion, registers from_python converters which use the
Expand Down
Loading