aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces
diff options
context:
space:
mode:
authorjimingham <jingham@apple.com>2025-11-11 11:06:40 -0800
committerGitHub <noreply@github.com>2025-11-11 11:06:40 -0800
commitccb5145460711928765432e2cbabac8ad526f8d0 (patch)
tree0040495558f1ebc142e30bdc3ddef3aeae3527cc /lldb/source/Plugins/ScriptInterpreter/Python/Interfaces
parent93b71e616288446041098cce4842e111cc054ed7 (diff)
downloadllvm-ccb5145460711928765432e2cbabac8ad526f8d0.tar.gz
llvm-ccb5145460711928765432e2cbabac8ad526f8d0.tar.bz2
llvm-ccb5145460711928765432e2cbabac8ad526f8d0.zip
Add a workaround for people that use *args instead of listing (#166883)
parameters when defining the scripting interfaces. We try to count the parameters to make sure the user has defined them correctly, but this throws the counting off. I'm not adding a test for this because then it would seem like we thought this was a good idea. I'd actually rather not support it altogether, but we added the parameter checking pretty recently so there are extant implementations that we broke. I only want to support them, not suggest anyone else do this going forward.
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/Interfaces')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index ec1dd9910d8a..af88a69e34a1 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -188,8 +188,13 @@ public:
// This addresses the cases where the embedded interpreter session
// dictionary is passed to the extension initializer which is not used
// most of the time.
+ // Note, though none of our API's suggest defining the interfaces with
+ // varargs, we have some extant clients that were doing that. To keep
+ // from breaking them, we just say putting a varargs in these signatures
+ // turns off argument checking.
size_t num_args = sizeof...(Args);
- if (num_args != arg_info->max_positional_args) {
+ if (arg_info->max_positional_args != PythonCallable::ArgInfo::UNBOUNDED &&
+ num_args != arg_info->max_positional_args) {
if (num_args != arg_info->max_positional_args - 1)
return create_error("Passed arguments ({0}) doesn't match the number "
"of expected arguments ({1}).",