From 99b0a9cdd7a70300cc935fe9edaa19cdcf968d24 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Thu, 26 Feb 2015 01:37:26 +0000 Subject: If we are trying to load the scripting resource for a module whose name happens to be a Python keyword, then prefix the filename with an _ (e.g. a module named def will load _def.py) Fixes rdar://13893506 llvm-svn: 230602 --- lldb/source/Interpreter/ScriptInterpreterPython.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 84472411e0f2..c28dcf99b4d4 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -195,7 +195,7 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete int old_count = Debugger::TestDebuggerRefCount(); - run_string.Printf ("run_one_line (%s, 'import copy, os, re, sys, uuid, lldb')", m_dictionary_name.c_str()); + run_string.Printf ("run_one_line (%s, 'import copy, keyword, os, re, sys, uuid, lldb')", m_dictionary_name.c_str()); PyRun_SimpleString (run_string.GetData()); // WARNING: temporary code that loads Cocoa formatters - this should be done on a per-platform basis rather than loading the whole set @@ -2582,6 +2582,21 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, } } +bool +ScriptInterpreterPython::IsReservedWord (const char* word) +{ + StreamString command_stream; + command_stream.Printf("keyword.iskeyword('%s')", word); + bool result; + ExecuteScriptOptions options; + options.SetEnableIO(false); + options.SetMaskoutErrors(true); + options.SetSetLLDBGlobals(false); + if (ExecuteOneLineWithReturn(command_stream.GetData(), ScriptInterpreter::eScriptReturnTypeBool, &result, options)) + return result; + return false; +} + lldb::ScriptInterpreterObjectSP ScriptInterpreterPython::MakeScriptObject (void* object) { -- cgit v1.2.3