[Lldb-commits] [lldb] r257398 - Fix Python 3 issues related to OS plugins.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 11 14:16:17 PST 2016


Author: zturner
Date: Mon Jan 11 16:16:17 2016
New Revision: 257398

URL: http://llvm.org/viewvc/llvm-project?rev=257398&view=rev
Log:
Fix Python 3 issues related to OS plugins.

* lldb::tid_t was being converted incorrectly, so this is updated to use
PythonInteger instead of manual Python Native API calls.
* OSPlugin_RegisterContextData was assuming that the result of
  get_register_data was a string, when in fact it is a bytes.  So this
  method is updated to use PythonBytes to do the work.

Modified:
    lldb/trunk/scripts/Python/python-typemaps.swig
    lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Modified: lldb/trunk/scripts/Python/python-typemaps.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-typemaps.swig?rev=257398&r1=257397&r2=257398&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-typemaps.swig (original)
+++ lldb/trunk/scripts/Python/python-typemaps.swig Mon Jan 11 16:16:17 2016
@@ -26,15 +26,17 @@
 }
 
 %typemap(in) lldb::tid_t {
-    if (PyInt_Check($input))
-        $1 = PyInt_AsLong($input);
-    else if (PyLong_Check($input))
-        $1 = PyLong_AsLongLong($input);
-    else
-    {
-        PyErr_SetString(PyExc_ValueError, "Expecting an integer");
-        return NULL;
-    }
+  using namespace lldb_private;
+  if (PythonInteger::Check($input))
+  {
+    PythonInteger py_int(PyRefType::Borrowed, $input);
+    $1 = static_cast<lldb::tid_t>(py_int.GetInteger());
+  }
+  else
+  {
+    PyErr_SetString(PyExc_ValueError, "Expecting an integer");
+    return nullptr;
+  }
 }
 
 %typemap(typecheck) char ** {

Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=257398&r1=257397&r2=257398&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Mon Jan 11 16:16:17 2016
@@ -1692,10 +1692,10 @@ ScriptInterpreterPython::OSPlugin_Regist
         PyErr_Clear();
     }
 
-    assert(PythonString::Check(py_return.get()) && "get_register_data returned unknown object type!");
+    assert(PythonBytes::Check(py_return.get()) && "get_register_data returned unknown object type!");
 
-    PythonString result_string(PyRefType::Borrowed, py_return.get());
-    return result_string.CreateStructuredString();
+    PythonBytes result(PyRefType::Borrowed, py_return.get());
+    return result.CreateStructuredString();
 }
 
 StructuredData::DictionarySP




More information about the lldb-commits mailing list