Skip to content

Commit 660487c

Browse files
berolinuxstefanseefeld
authored andcommitted
Fix build with Python 3.7
Python 3.7 changes the return type of _PyUnicode_AsString() from void* to const char* -- causing the build of boost-python to fail. Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
1 parent d6d54ce commit 660487c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/converter/builtin_converters.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ namespace
4545
{
4646
return PyString_Check(obj) ? PyString_AsString(obj) : 0;
4747
}
48-
#else
48+
#elif PY_VERSION_HEX < 0x03070000
4949
void* convert_to_cstring(PyObject* obj)
5050
{
5151
return PyUnicode_Check(obj) ? _PyUnicode_AsString(obj) : 0;
5252
}
53+
#else
54+
void* convert_to_cstring(PyObject* obj)
55+
{
56+
return PyUnicode_Check(obj) ? const_cast<void*>(reinterpret_cast<const void*>(_PyUnicode_AsString(obj))) : 0;
57+
}
5358
#endif
5459

5560
// Given a target type and a SlotPolicy describing how to perform a

0 commit comments

Comments
 (0)