[Lldb-commits] [lldb] Add a workaround for people that use *args instead of listing (PR #166883)

via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 7 09:19:55 PST 2025


https://github.com/jimingham updated https://github.com/llvm/llvm-project/pull/166883

>From 18ec34762e70fc9f56c80118923ec6b981dbd374 Mon Sep 17 00:00:00 2001
From: Jim Ingham <jingham at apple.com>
Date: Thu, 6 Nov 2025 18:23:06 -0800
Subject: [PATCH 1/2] Add a workaround for people that use *args instead of
 listing 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.
---
 .../Python/Interfaces/ScriptedPythonInterface.h            | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 2335b2ef0f171..31f38444b04cd 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -188,8 +188,13 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
       // 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}).",

>From d0b54a07781df04beb770ae1e7fcf35f246dc625 Mon Sep 17 00:00:00 2001
From: Jim Ingham <jingham at apple.com>
Date: Fri, 7 Nov 2025 09:19:37 -0800
Subject: [PATCH 2/2] formatting

---
 .../Python/Interfaces/ScriptedPythonInterface.h             | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 31f38444b04cd..5f81335e3e1b1 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -189,12 +189,12 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
       // 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 
+      // 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 (arg_info->max_positional_args != PythonCallable::ArgInfo::UNBOUNDED 
-          && 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}).",



More information about the lldb-commits mailing list