get rid of PythonInteger::GetInteger()

Summary:
One small step in my long running quest to improve python exception handling in
LLDB.  Replace GetInteger() which just returns an int with As<long long> and
friends, which return Expected types that can track python exceptions

Reviewers: labath, jasonmolenda, JDevlieghere, vadimcn

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78462
This commit is contained in:
Lawrence D'Anna
2020-04-21 16:53:47 -07:00
parent dad6de4112
commit 7375212172
6 changed files with 115 additions and 118 deletions

View File

@@ -3150,20 +3150,15 @@ uint32_t ScriptInterpreterPythonImpl::GetFlagsForCommandObject(
if (PyErr_Occurred())
PyErr_Clear();
// right now we know this function exists and is callable..
PythonObject py_return(
PyRefType::Owned,
PyObject_CallMethod(implementor.get(), callee_name, nullptr));
long long py_return = unwrapOrSetPythonException(
As<long long>(implementor.CallMethod(callee_name)));
// if it fails, print the error but otherwise go on
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
}
if (py_return.IsAllocated() && PythonInteger::Check(py_return.get())) {
PythonInteger int_value(PyRefType::Borrowed, py_return.get());
result = int_value.GetInteger();
} else {
result = py_return;
}
return result;