2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 04:22:16 +00:00

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>
This commit is contained in:
Bernhard Rosenkränzer
2018-02-09 18:20:30 +01:00
committed by Stefan Seefeld
parent d6d54ce483
commit 660487c43f

View File

@@ -45,11 +45,16 @@ namespace
{
return PyString_Check(obj) ? PyString_AsString(obj) : 0;
}
#else
#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)
{
return PyUnicode_Check(obj) ? const_cast<void*>(reinterpret_cast<const void*>(_PyUnicode_AsString(obj))) : 0;
}
#endif
// Given a target type and a SlotPolicy describing how to perform a