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
This commit is contained in:
Enrico Granata
2015-02-26 01:37:26 +00:00
parent 5017ab5d0e
commit 99b0a9cdd7
4 changed files with 40 additions and 4 deletions

View File

@@ -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)
{