diff options
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 6b53bd3..c2fd1f2 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -2781,6 +2781,7 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule( }; std::string module_name(pathname); + bool possible_package = false; if (extra_search_dir) { if (llvm::Error e = ExtendSysPath(extra_search_dir.GetPath())) { @@ -2805,6 +2806,7 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule( return false; } // Not a filename, probably a package of some sort, let it go through. + possible_package = true; } else if (is_directory(st) || is_regular_file(st)) { if (module_file.GetDirectory().IsEmpty()) { error.SetErrorString("invalid directory name"); @@ -2831,6 +2833,18 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule( module_name.resize(module_name.length() - 4); } + if (!possible_package && module_name.find('.') != llvm::StringRef::npos) { + error.SetErrorStringWithFormat( + "Python does not allow dots in module names: %s", module_name.c_str()); + return false; + } + + if (module_name.find('-') != llvm::StringRef::npos) { + error.SetErrorStringWithFormat( + "Python discourages dashes in module names: %s", module_name.c_str()); + return false; + } + // check if the module is already import-ed StreamString command_stream; command_stream.Clear(); |