From fac939e918558d88b80561e764989e95a5576b1c Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Tue, 18 Sep 2012 21:53:02 +0000 Subject: Fixing a problem where a Python command created in the same module where the target function is defined causes the help string not to come out llvm-svn: 164172 --- lldb/source/Interpreter/ScriptInterpreterPython.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index fec70e301cc5..d0858739b12c 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -2542,9 +2542,12 @@ ScriptInterpreterPython::RunScriptBasedCommand(const char* impl_function, // in Python, a special attribute __doc__ contains the docstring // for an object (function, method, class, ...) if any is defined // Otherwise, the attribute's value is None -std::string -ScriptInterpreterPython::GetDocumentationForItem(const char* item) +bool +ScriptInterpreterPython::GetDocumentationForItem(const char* item, std::string& dest) { + dest.clear(); + if (!item || !*item) + return false; std::string command(item); command += ".__doc__"; @@ -2554,10 +2557,16 @@ ScriptInterpreterPython::GetDocumentationForItem(const char* item) ScriptInterpreter::eScriptReturnTypeCharStrOrNone, &result_ptr, false) && result_ptr) { - return std::string(result_ptr); + dest.assign(result_ptr); + return true; } else - return std::string(""); + { + StreamString str_stream; + str_stream.Printf("Function %s was not found. Containing module might be missing.",item); + dest.assign(str_stream.GetData()); + return false; + } } void -- cgit v1.2.3