summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-12-04 22:59:14 +0000
committerZachary Turner <zturner@google.com>2015-12-04 22:59:14 +0000
commit7d2d09842a428bc0b45414ff0f32391a447e048d (patch)
tree486f1c62cd4b9eabe7fbbcf17fa33eb0022ee3ae /lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
parent6dd8aa2ed26bef9db6b07464117035a1d87bf417 (diff)
downloadbcm5719-llvm-7d2d09842a428bc0b45414ff0f32391a447e048d.tar.gz
bcm5719-llvm-7d2d09842a428bc0b45414ff0f32391a447e048d.zip
Python 3 - Fix script import --allow-reload.
Differential Revision: http://reviews.llvm.org/D15209 Reviewed By: Todd Fiala llvm-svn: 254791
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 40a01ea30a7..b1dd34b46f6 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -286,10 +286,15 @@ ScriptInterpreterPython::ScriptInterpreterPython(CommandInterpreter &interpreter
PyRun_SimpleString (run_string.GetData());
run_string.Clear();
-
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());
+ // Reloading modules requires a different syntax in Python 2 and Python 3. This provides
+ // a consistent syntax no matter what version of Python.
+ run_string.Clear();
+ run_string.Printf("run_one_line (%s, 'from six.moves import reload_module')", 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
// and letting the individual formatter classes exploit APIs to check whether they can/cannot do their task
run_string.Clear();
@@ -2626,9 +2631,9 @@ ScriptInterpreterPython::LoadScriptingModule(const char *pathname, bool can_relo
if (was_imported)
{
if (!was_imported_locally)
- command_stream.Printf("import %s ; reload(%s)",basename.c_str(),basename.c_str());
+ command_stream.Printf("import %s ; reload_module(%s)",basename.c_str(),basename.c_str());
else
- command_stream.Printf("reload(%s)",basename.c_str());
+ command_stream.Printf("reload_module(%s)",basename.c_str());
}
else
command_stream.Printf("import %s",basename.c_str());
OpenPOWER on IntegriCloud