[Lldb-commits] [PATCH] D68188: allow arbitrary python streams to be converted to SBFile

Lawrence D'Anna via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 4 09:31:27 PDT 2019

lawrence_danna added inline comments.

Comment at: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp:1369
+    const char *utf8 = PyUnicode_AsUTF8AndSize(pystring.get(), &size);
+    if (!utf8 || PyErr_Occurred())
+      return Status(llvm::make_error<PythonException>("Read"));
labath wrote:
> This is an example where _I think_ you may be using `PyErr_Occurred` incorrectly. If python really asserts that PyErr_Occurred is always called, then this is not right, as you will not call it if the result is null. There are a couple of other examples like that in the code too.
I think it is correct.

Python doesn't assert that PyErr_Occured is called, it asserts that the error is cleared before you call back in to another thing that can cause an error.    PythonException will clear the error if there is one, or say "unknown error" if there isn't one (which should never happen if utf8==NULL, but i'm checking out of abundance of caution)

  rG LLVM Github Monorepo



More information about the lldb-commits mailing list