[Lldb-commits] [lldb] [lldb] Remove import statement in lldb.command decorator (PR #188294)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 26 11:08:22 PDT 2026


https://github.com/kastiglione updated https://github.com/llvm/llvm-project/pull/188294

>From 93a4d77c937e02f6da875fe12a292f5b5025eb0f Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Wed, 18 Feb 2026 09:36:08 -0800
Subject: [PATCH 1/2] [lldb] Remove import statement in lldb.command decorator

---
 lldb/bindings/python/python-extensions.swig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/bindings/python/python-extensions.swig b/lldb/bindings/python/python-extensions.swig
index 40fa76872ee96..63098b74eea41 100644
--- a/lldb/bindings/python/python-extensions.swig
+++ b/lldb/bindings/python/python-extensions.swig
@@ -269,13 +269,13 @@
 %pythoncode %{
 
 def command(command_name=None, doc=None):
-    import lldb
     """A decorator function that registers an LLDB command line
         command that is bound to the function it is attached to."""
     def callable(function):
         """Registers an lldb command for the decorated function."""
         command = "command script add -f %s.%s %s" % (function.__module__, function.__name__, command_name or function.__name__)
-        lldb.debugger.HandleCommand(command)
+        global debugger
+        debugger.HandleCommand(command)
         if doc:
             function.__doc__ = doc
         return function

>From 7a913de3ede1b745a8379286c33a897dd61cee2a Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Thu, 26 Mar 2026 11:07:46 -0700
Subject: [PATCH 2/2] Remove optional global declaration

---
 lldb/bindings/python/python-extensions.swig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lldb/bindings/python/python-extensions.swig b/lldb/bindings/python/python-extensions.swig
index 63098b74eea41..c0319e3dc77bb 100644
--- a/lldb/bindings/python/python-extensions.swig
+++ b/lldb/bindings/python/python-extensions.swig
@@ -274,7 +274,6 @@ def command(command_name=None, doc=None):
     def callable(function):
         """Registers an lldb command for the decorated function."""
         command = "command script add -f %s.%s %s" % (function.__module__, function.__name__, command_name or function.__name__)
-        global debugger
         debugger.HandleCommand(command)
         if doc:
             function.__doc__ = doc



More information about the lldb-commits mailing list