This revision was automatically updated to reflect the committed changes. Closed by commit rG1197ee35b84e: [lldb] Unconditionally strip the `.py(c)` extension when loading a module (authored by JDevlieghere). Herald added a project: LLDB.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D89352/new/ https://reviews.llvm.org/D89352 Files: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -2797,19 +2797,20 @@ return false; } - // strip .py or .pyc extension - ConstString extension = target_file.GetFileNameExtension(); - if (extension) { - if (llvm::StringRef(extension.GetCString()) == ".py") - basename.resize(basename.length() - 3); - else if (llvm::StringRef(extension.GetCString()) == ".pyc") - basename.resize(basename.length() - 4); - } } else { error.SetErrorString("no known way to import this module specification"); return false; } + // Strip .py or .pyc extension + llvm::StringRef extension = target_file.GetFileNameExtension().GetCString(); + if (!extension.empty()) { + if (extension == ".py") + basename.resize(basename.length() - 3); + else if (extension == ".pyc") + basename.resize(basename.length() - 4); + } + // check if the module is already import-ed command_stream.Clear(); command_stream.Printf("sys.modules.__contains__('%s')", basename.c_str());
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -2797,19 +2797,20 @@ return false; } - // strip .py or .pyc extension - ConstString extension = target_file.GetFileNameExtension(); - if (extension) { - if (llvm::StringRef(extension.GetCString()) == ".py") - basename.resize(basename.length() - 3); - else if (llvm::StringRef(extension.GetCString()) == ".pyc") - basename.resize(basename.length() - 4); - } } else { error.SetErrorString("no known way to import this module specification"); return false; } + // Strip .py or .pyc extension + llvm::StringRef extension = target_file.GetFileNameExtension().GetCString(); + if (!extension.empty()) { + if (extension == ".py") + basename.resize(basename.length() - 3); + else if (extension == ".pyc") + basename.resize(basename.length() - 4); + } + // check if the module is already import-ed command_stream.Clear(); command_stream.Printf("sys.modules.__contains__('%s')", basename.c_str());
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits