From adbf64ccc9e18278600ebaeadd8f0117eb8e64b1 Mon Sep 17 00:00:00 2001 From: Lawrence D'Anna Date: Mon, 4 Nov 2019 12:48:49 -0800 Subject: [LLDB][Python] remove ArgInfo::count Summary: This patch updates the last user of ArgInfo::count and deletes it. I also delete `GetNumInitArguments()` and `GetInitArgInfo()`. Classess are callables and `GetArgInfo()` should work on them. On python 3 it already works, of course. `inspect` is good. On python 2 we have to add yet another special case. But hey if python 2 wasn't crufty we wouln't need python 3. I also delete `is_bound_method` becuase it is unused. This path is tested in `TestStepScripted.py` Reviewers: labath, mgorny, JDevlieghere Reviewed By: labath, JDevlieghere Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D69742 --- lldb/scripts/Python/python-wrapper.swig | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'lldb/scripts/Python/python-wrapper.swig') diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig index 71a958a..3a63165 100644 --- a/lldb/scripts/Python/python-wrapper.swig +++ b/lldb/scripts/Python/python-wrapper.swig @@ -291,20 +291,32 @@ LLDBSwigPythonCreateScriptedThreadPlan if (!tp_arg.IsAllocated()) Py_RETURN_NONE; + llvm::Expected arg_info = pfunc.GetArgInfo(); + if (!arg_info) { + llvm::handleAllErrors( + arg_info.takeError(), + [&](PythonException &E) { + error_string.append(E.ReadBacktrace()); + }, + [&](const llvm::ErrorInfoBase &E) { + error_string.append(E.message()); + }); + Py_RETURN_NONE; + } + PythonObject result = {}; - size_t init_num_args = pfunc.GetNumInitArguments().count; - if (init_num_args == 3) { + if (arg_info.get().max_positional_args == 2) { if (args_impl != nullptr) { error_string.assign("args passed, but __init__ does not take an args dictionary"); Py_RETURN_NONE; } result = pfunc(tp_arg, dict); - } else if (init_num_args == 4) { + } else if (arg_info.get().max_positional_args >= 3) { lldb::SBStructuredData *args_value = new lldb::SBStructuredData(args_impl); PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(args_value)); result = pfunc(tp_arg, args_arg, dict); } else { - error_string.assign("wrong number of arguments in __init__, should be 1 or 2 (not including self & dict)"); + error_string.assign("wrong number of arguments in __init__, should be 2 or 3 (not including self)"); Py_RETURN_NONE; } -- cgit v1.1