home · contact · privacy
Prevent recursion with __cmd_prompt_enter potentially calling itself. master
authorChristian Heller <c.heller@plomlompom.de>
Sat, 31 May 2025 05:11:06 +0000 (07:11 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 31 May 2025 05:11:06 +0000 (07:11 +0200)
ircplom.py

index 68b510986132f60114268e7d37328c96c3bdf227..ce447d7d0f37475b122e58ee3550bbb1773685a8 100755 (executable)
@@ -2,7 +2,7 @@
 'Attempt at an IRC client.'
 
 from contextlib import contextmanager
-from inspect import _empty as inspect_empty, signature
+from inspect import _empty as inspect_empty, signature, stack
 from queue import SimpleQueue, Empty as QueueEmpty
 from signal import SIGWINCH, signal
 from socket import socket
@@ -494,7 +494,8 @@ class TuiLoop(Loop):
             if len(self._prompt) > 1 and self._prompt[0] == '/':
                 toks = self._prompt[1:].split(maxsplit=1)
                 method_name = f'_cmd__{toks[0]}'
-                if hasattr(self, method_name):
+                if hasattr(self, method_name)\
+                        and method_name != stack()[0].function:
                     method = getattr(self, method_name)
                     params = signature(method).parameters
                     n_args_max = len(params)