From 1553714b0093a8ef907faf3b3145c224caa7364a Mon Sep 17 00:00:00 2001 From: David Spickett Date: Fri, 20 Sep 2024 15:18:45 +0100 Subject: Revert "[lldb] Change the implementation of Status to store an llvm::Error (NFC) (#106774)" This reverts commit 104b249c236578d298384416c495ff7310b97f4d because it has caused 2 test failures on Windows: https://lab.llvm.org/buildbot/#/builders/141/builds/2544 Failed Tests (2): lldb-api :: functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py lldb-unit :: Utility/./UtilityTests.exe/StatusTest/ErrorWin32 I reckon the cause is the same, that we construct an error with the Win32 NO_ERROR value which means there was no error but we're assuming anything with an error code is a failure. --- .../ScriptInterpreter/Python/PythonDataObjects.cpp | 29 ++++++++-------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 90ccd10..24cf3430 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -1108,10 +1108,9 @@ public: py_error = Status::FromError(r.takeError()); } base_error = Base::Close(); - // Cloning since the wrapped exception may still reference the PyThread. if (py_error.Fail()) - return py_error.Clone(); - return base_error.Clone(); + return py_error; + return base_error; }; PyObject *GetPythonObject() const { @@ -1197,8 +1196,7 @@ public: return Flush(); auto r = m_py_obj.CallMethod("close"); if (!r) - // Cloning since the wrapped exception may still reference the PyThread. - return Status::FromError(r.takeError()).Clone(); + return Status::FromError(r.takeError()); return Status(); } @@ -1206,8 +1204,7 @@ public: GIL takeGIL; auto r = m_py_obj.CallMethod("flush"); if (!r) - // Cloning since the wrapped exception may still reference the PyThread. - return Status::FromError(r.takeError()).Clone(); + return Status::FromError(r.takeError()); return Status(); } @@ -1243,8 +1240,7 @@ public: PyObject *pybuffer_p = PyMemoryView_FromMemory( const_cast((const char *)buf), num_bytes, PyBUF_READ); if (!pybuffer_p) - // Cloning since the wrapped exception may still reference the PyThread. - return Status::FromError(llvm::make_error()).Clone(); + return Status::FromError(llvm::make_error()); auto pybuffer = Take(pybuffer_p); num_bytes = 0; auto bytes_written = As(m_py_obj.CallMethod("write", pybuffer)); @@ -1264,8 +1260,7 @@ public: auto pybuffer_obj = m_py_obj.CallMethod("read", (unsigned long long)num_bytes); if (!pybuffer_obj) - // Cloning since the wrapped exception may still reference the PyThread. - return Status::FromError(pybuffer_obj.takeError()).Clone(); + return Status::FromError(pybuffer_obj.takeError()); num_bytes = 0; if (pybuffer_obj.get().IsNone()) { // EOF @@ -1274,8 +1269,7 @@ public: } auto pybuffer = PythonBuffer::Create(pybuffer_obj.get()); if (!pybuffer) - // Cloning since the wrapped exception may still reference the PyThread. - return Status::FromError(pybuffer.takeError()).Clone(); + return Status::FromError(pybuffer.takeError()); memcpy(buf, pybuffer.get().get().buf, pybuffer.get().get().len); num_bytes = pybuffer.get().get().len; return Status(); @@ -1306,8 +1300,7 @@ public: auto bytes_written = As(m_py_obj.CallMethod("write", pystring.get())); if (!bytes_written) - // Cloning since the wrapped exception may still reference the PyThread. - return Status::FromError(bytes_written.takeError()).Clone(); + return Status::FromError(bytes_written.takeError()); if (bytes_written.get() < 0) return Status::FromErrorString( ".write() method returned a negative number!"); @@ -1328,16 +1321,14 @@ public: auto pystring = As( m_py_obj.CallMethod("read", (unsigned long long)num_chars)); if (!pystring) - // Cloning since the wrapped exception may still reference the PyThread. - return Status::FromError(pystring.takeError()).Clone(); + return Status::FromError(pystring.takeError()); if (pystring.get().IsNone()) { // EOF return Status(); } auto stringref = pystring.get().AsUTF8(); if (!stringref) - // Cloning since the wrapped exception may still reference the PyThread. - return Status::FromError(stringref.takeError()).Clone(); + return Status::FromError(stringref.takeError()); num_bytes = stringref.get().size(); memcpy(buf, stringref.get().begin(), num_bytes); return Status(); -- cgit v1.1