diff options
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
3 files changed, 7 insertions, 35 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index e2112b15008..8c0618cd91a 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -837,25 +837,6 @@ bool PythonFile::Check(PyObject *py_obj) { #endif } -FileUP PythonFile::GetUnderlyingFile() const { - if (!IsValid()) - return nullptr; - - // We don't own the file descriptor returned by this function, make sure the - // File object knows about that. - PythonString py_mode = GetAttributeValue("mode").AsType<PythonString>(); - auto options = File::GetOptionsFromMode(py_mode.GetString()); - if (!options) { - llvm::consumeError(options.takeError()); - return nullptr; - } - auto file = std::unique_ptr<File>(new NativeFile( - PyObject_AsFileDescriptor(m_py_obj), options.get(), false)); - if (!file->IsValid()) - return nullptr; - return file; -} - namespace { class GIL { public: diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h index 43ffd8d339b..255fa06c057 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h @@ -637,20 +637,6 @@ public: static llvm::Expected<PythonFile> FromFile(File &file, const char *mode = nullptr); - // FIXME delete this after FILE* typemaps are deleted - // and ScriptInterpreterPython is fixed - PythonFile(File &file, const char *mode = nullptr) { - auto f = FromFile(file, mode); - if (f) - *this = std::move(f.get()); - else { - Reset(); - llvm::consumeError(f.takeError()); - } - } - - lldb::FileUP GetUnderlyingFile() const; - llvm::Expected<lldb::FileSP> ConvertToFile(bool borrowed = false); llvm::Expected<lldb::FileSP> ConvertToFileForcingUseOfScriptingIOMethods(bool borrowed = false); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index d773fd8d258..70654a42384 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -651,10 +651,15 @@ bool ScriptInterpreterPythonImpl::SetStdHandle(FileSP file_sp, PythonDictionary &sys_module_dict = GetSysModuleDictionary(); + auto new_file = PythonFile::FromFile(file, mode); + if (!new_file) { + llvm::consumeError(new_file.takeError()); + return false; + } + save_file = sys_module_dict.GetItemForKey(PythonString(py_name)); - PythonFile new_file(file, mode); - sys_module_dict.SetItemForKey(PythonString(py_name), new_file); + sys_module_dict.SetItemForKey(PythonString(py_name), new_file.get()); return true; } |