[Lldb-commits] [lldb] r337908 - Fix PythonString::GetString for >=python-3.7
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 25 04:35:28 PDT 2018
Author: labath
Date: Wed Jul 25 04:35:28 2018
New Revision: 337908
URL: http://llvm.org/viewvc/llvm-project?rev=337908&view=rev
Log:
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.
Modified:
lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp?rev=337908&r1=337907&r2=337908&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp Wed Jul 25 04:35:28 2018
@@ -399,14 +399,16 @@ llvm::StringRef PythonString::GetString(
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 {
More information about the lldb-commits
mailing list