aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorLawrence D'Anna <lawrence_danna@apple.com>2020-05-08 10:56:30 -0700
committerLawrence D'Anna <lawrence_danna@apple.com>2020-05-08 10:57:10 -0700
commit52712d3ff7a2f7bcf737996d6ab59ef2cc29c20d (patch)
treecf0b823eed5f3fc69e1a11f43b028d29b5b20992 /lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
parentae920a81ffa3c7e3c14de131d0d55abd31bbff7d (diff)
downloadllvm-52712d3ff7a2f7bcf737996d6ab59ef2cc29c20d.zip
llvm-52712d3ff7a2f7bcf737996d6ab59ef2cc29c20d.tar.gz
llvm-52712d3ff7a2f7bcf737996d6ab59ef2cc29c20d.tar.bz2
Re-land "get rid of PythonInteger::GetInteger()"
This was reverted due to a python2-specific bug. Re-landing with a fix for python2. 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, omjavaid Reviewed By: labath, omjavaid Subscribers: omjavaid, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D78462
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index c53b3bd..6f26677 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -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;