[Lldb-commits] [lldb] r182953 - This checkin enables Python summaries to return any string-convertible object
Enrico Granata
egranata at apple.com
Thu May 30 11:56:48 PDT 2013
Author: enrico
Date: Thu May 30 13:56:47 2013
New Revision: 182953
URL: http://llvm.org/viewvc/llvm-project?rev=182953&view=rev
Log:
This checkin enables Python summaries to return any string-convertible object
Upon encountering an object not of type string, LLDB will get the string representation of it (akin to calling str(X) in Python code) and use that as the summary to display
Feedback is welcome as to whether repr() should be used instead (but the argument for repr() better be highly persuasive :-)
Modified:
lldb/trunk/scripts/Python/python-wrapper.swig
Modified: lldb/trunk/scripts/Python/python-wrapper.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=182953&r1=182952&r2=182953&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-wrapper.swig (original)
+++ lldb/trunk/scripts/Python/python-wrapper.swig Thu May 30 13:56:47 2013
@@ -318,8 +318,18 @@ LLDBSwigPythonCallTypeScript
pvalue = PyObject_CallObject (pfunc, pargs);
Py_DECREF (pargs);
- if (pvalue != NULL && pvalue != Py_None && PyString_Check(pvalue))
- retval.assign(PyString_AsString(pvalue));
+ if (pvalue != NULL && pvalue != Py_None)
+ {
+ if (PyString_Check(pvalue))
+ retval.assign(PyString_AsString(pvalue));
+ else
+ {
+ PyObject* value_as_string = PyObject_Str(pvalue);
+ if (value_as_string && value_as_string != Py_None && PyString_Check(value_as_string))
+ retval.assign(PyString_AsString(value_as_string));
+ Py_XDECREF(value_as_string);
+ }
+ }
Py_XDECREF (pvalue);
Py_INCREF (session_dict);
}
More information about the lldb-commits
mailing list