[Lldb-commits] [lldb] [lldb] Use Python Bytes instead of Buffer for Binary I/O (NFC) (PR #152031)

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 4 14:34:14 PDT 2025


================
@@ -1212,12 +1178,12 @@ class BinaryPythonFile : public PythonIOFile {
       num_bytes = 0;
       return Status();
     }
-    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();
-    memcpy(buf, pybuffer.get().get().buf, pybuffer.get().get().len);
-    num_bytes = pybuffer.get().get().len;
+    PythonBytes pybytes(PyRefType::Borrowed, pybuffer_obj->get());
+    if (!pybytes)
+      return Status::FromErrorString("not a byte array");
----------------
bulbazord wrote:

This subtly changes behavior from raising a python exception to returning the string "not a byte array". Is that not a breaking change?

https://github.com/llvm/llvm-project/pull/152031


More information about the lldb-commits mailing list