summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2015-02-26 01:37:26 +0000
committerEnrico Granata <egranata@apple.com>2015-02-26 01:37:26 +0000
commit99b0a9cdd7a70300cc935fe9edaa19cdcf968d24 (patch)
tree4764fe03aa327bf3fbfcc223e4fbd16f3c89315b /lldb/source/Interpreter/ScriptInterpreterPython.cpp
parent5017ab5d0eb59d20babc245961c2039d43d9b8cc (diff)
downloadbcm5719-llvm-99b0a9cdd7a70300cc935fe9edaa19cdcf968d24.tar.gz
bcm5719-llvm-99b0a9cdd7a70300cc935fe9edaa19cdcf968d24.zip
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
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 84472411e0f..c28dcf99b4d 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)
{
OpenPOWER on IntegriCloud