Author: zturner Date: Fri Dec 4 16:59:14 2015 New Revision: 254791 URL: http://llvm.org/viewvc/llvm-project?rev=254791&view=rev Log: Python 3 - Fix script import --allow-reload.
Differential Revision: http://reviews.llvm.org/D15209 Reviewed By: Todd Fiala Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=254791&r1=254790&r2=254791&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Fri Dec 4 16:59:14 2015 @@ -286,10 +286,15 @@ ScriptInterpreterPython::ScriptInterpret 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::LoadScriptingMo 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()); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits