From 5457b426f5e15a29c0acc8af1a476132f8be2a36 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 25 Jul 2018 11:35:28 +0000 Subject: 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 --- .../source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lldb') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 6a9d57d5a30..90d8ab97fb7 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -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 { -- cgit v1.2.1