diff options
-rw-r--r-- | lldb/scripts/Python/interface/SBCommandReturnObject.i | 2 | ||||
-rw-r--r-- | lldb/scripts/Python/python-typemaps.swig | 23 | ||||
-rw-r--r-- | lldb/source/API/SBCommandReturnObject.cpp | 2 |
3 files changed, 25 insertions, 2 deletions
diff --git a/lldb/scripts/Python/interface/SBCommandReturnObject.i b/lldb/scripts/Python/interface/SBCommandReturnObject.i index e72c1e2731f..7cec06943bf 100644 --- a/lldb/scripts/Python/interface/SBCommandReturnObject.i +++ b/lldb/scripts/Python/interface/SBCommandReturnObject.i @@ -84,7 +84,7 @@ public: SetImmediateErrorFile (FILE *fh); void - PutCString(const char* string, int len = -1); + PutCString(const char* string, int len); // wrapping the variadic Printf() with a plain Print() // because it is hard to support varargs in SWIG bridgings diff --git a/lldb/scripts/Python/python-typemaps.swig b/lldb/scripts/Python/python-typemaps.swig index 1a67f7b4971..8af1446aef3 100644 --- a/lldb/scripts/Python/python-typemaps.swig +++ b/lldb/scripts/Python/python-typemaps.swig @@ -442,3 +442,26 @@ #endif $result = PyFile_FromFile($1, const_cast<char*>(""), mode, fclose); } + +%typemap(in) (const char* string, int len) { + if ($input == Py_None) + { + $1 = NULL; + $2 = 0; + } + else if (PyUnicode_Check($input)) + { + $1 = PyString_AsString(PyUnicode_AsUTF8String($input)); + $2 = strlen($1); + } + else if (PyString_Check($input)) + { + $1 = PyString_AsString($input); + $2 = PyString_Size($input); + } + else + { + PyErr_SetString(PyExc_TypeError,"not a string-like object"); + return NULL; + } +} diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index ee7008af3c7..b0533e132db 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -281,7 +281,7 @@ SBCommandReturnObject::PutCString(const char* string, int len) { if (m_opaque_ap.get()) { - if (len == 0) + if (len == 0 || string == NULL || *string == 0) { return; } |