Fix PythonString::GetString for >=python-3.7

The return value of PyUnicode_AsUTF8AndSize is now "const char *".

Thanks to Brett Neumeier for testing the patch out on python 3.7.

llvm-svn: 337908
This commit is contained in:
Pavel Labath
2018-07-25 11:35:28 +00:00
parent 84bd5db209
commit 5457b426f5

View File

@@ -399,14 +399,16 @@ llvm::StringRef PythonString::GetString() const {
return llvm::StringRef();
Py_ssize_t size;
char *c;
const char *data;
#if PY_MAJOR_VERSION >= 3
c = PyUnicode_AsUTF8AndSize(m_py_obj, &size);
data = PyUnicode_AsUTF8AndSize(m_py_obj, &size);
#else
char *c;
PyString_AsStringAndSize(m_py_obj, &c, &size);
data = c;
#endif
return llvm::StringRef(c, size);
return llvm::StringRef(data, size);
}
size_t PythonString::GetSize() const {