[Python] Update PyString_FromString() to work for python 2 and 3.
authorDavide Italiano <davide@freebsd.org>
Wed, 9 Jan 2019 22:52:47 +0000 (22:52 +0000)
committerDavide Italiano <davide@freebsd.org>
Wed, 9 Jan 2019 22:52:47 +0000 (22:52 +0000)
Reviewers: aprantl, JDevlieghere, friss, zturner

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D56511

llvm-svn: 350769

lldb/scripts/Python/python-swigsafecast.swig
lldb/scripts/Python/python-wrapper.swig

index 57ae00c..d5cafbf 100644 (file)
@@ -27,15 +27,6 @@ SBTypeToSWIGWrapper (PyObject* py_object)
 
 template <>
 PyObject*
-SBTypeToSWIGWrapper (const char* c_str)
-{
-    if (c_str)
-        return PyString_FromString(c_str);
-    return NULL;
-}
-
-template <>
-PyObject*
 SBTypeToSWIGWrapper (unsigned int* c_int)
 {
     if (!c_int)
index e6a6b7a..8509899 100644 (file)
@@ -826,7 +826,9 @@ LLDBSwigPython_GetRecognizedArguments
     lldb::SBFrame frame_sb(frame_sp);
     PyObject *arg = SBTypeToSWIGWrapper(frame_sb);
 
-    PyObject* result = PyObject_CallMethodObjArgs(implementor, PyString_FromString(callee_name), arg, NULL);
+    PythonString str(callee_name);
+    PyObject* result = PyObject_CallMethodObjArgs(implementor, str.get(), arg,
+                                                  NULL);
     return result;
 }