summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/python-wrapper.swig
diff options
context:
space:
mode:
authorLawrence D'Anna <lawrence_danna@apple.com>2019-11-04 12:48:49 -0800
committerLawrence D'Anna <lawrence_danna@apple.com>2019-11-04 12:48:49 -0800
commitadbf64ccc9e18278600ebaeadd8f0117eb8e64b1 (patch)
tree4dd857d012749bea97dd4ddbbaeb0d28ff006621 /lldb/scripts/Python/python-wrapper.swig
parent4312c4afd43209400df53ca541b4b19919f797af (diff)
downloadbcm5719-llvm-adbf64ccc9e18278600ebaeadd8f0117eb8e64b1.tar.gz
bcm5719-llvm-adbf64ccc9e18278600ebaeadd8f0117eb8e64b1.zip
[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
Diffstat (limited to 'lldb/scripts/Python/python-wrapper.swig')
-rw-r--r--lldb/scripts/Python/python-wrapper.swig20
1 files changed, 16 insertions, 4 deletions
diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig
index 71a958acb72..3a63165cf58 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<PythonCallable::ArgInfo> 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;
}
OpenPOWER on IntegriCloud