public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add keywords to TuiWindow.write
@ 2023-12-13  5:53 Tom Tromey
  2023-12-30 19:22 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-12-13  5:53 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The gdb docs promise that methods with more than two or more arguments
will accept keywords.  However, I found that TuiWindow.write didn't
allow them.  This patch adds the missing support.
---
 gdb/python/py-tui.c                    | 9 ++++++---
 gdb/testsuite/gdb.python/tui-window.py | 3 ++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index a84e38a0563..a28137ee78f 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -476,13 +476,16 @@ gdbpy_tui_erase (PyObject *self, PyObject *args)
 
 /* Python function that writes some text to a TUI window.  */
 static PyObject *
-gdbpy_tui_write (PyObject *self, PyObject *args)
+gdbpy_tui_write (PyObject *self, PyObject *args, PyObject *kw)
 {
+  static const char *keywords[] = { "string", "full_window", nullptr };
+
   gdbpy_tui_window *win = (gdbpy_tui_window *) self;
   const char *text;
   int full_window = 0;
 
-  if (!PyArg_ParseTuple (args, "s|i", &text, &full_window))
+  if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords,
+					&text, &full_window))
     return nullptr;
 
   REQUIRE_WINDOW (win);
@@ -562,7 +565,7 @@ static PyMethodDef tui_object_methods[] =
 Return true if this TUI window is valid, false if not." },
   { "erase", gdbpy_tui_erase, METH_NOARGS,
     "Erase the TUI window." },
-  { "write", (PyCFunction) gdbpy_tui_write, METH_VARARGS,
+  { "write", (PyCFunction) gdbpy_tui_write, METH_VARARGS | METH_KEYWORDS,
     "Append a string to the TUI window." },
   { NULL } /* Sentinel.  */
 };
diff --git a/gdb/testsuite/gdb.python/tui-window.py b/gdb/testsuite/gdb.python/tui-window.py
index dc72cc4c0f7..47c4403bc48 100644
--- a/gdb/testsuite/gdb.python/tui-window.py
+++ b/gdb/testsuite/gdb.python/tui-window.py
@@ -32,7 +32,8 @@ class TestWindow:
         self.win.erase()
         w = self.win.width
         h = self.win.height
-        self.win.write("Test: " + str(self.count) + " " + str(w) + "x" + str(h))
+        self.win.write(string="Test: " + str(self.count) + " " + str(w) + "x" + str(h),
+                       full_window=False)
         self.count = self.count + 1
 
     # Tries to delete the title attribute.  GDB will throw an error.
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add keywords to TuiWindow.write
  2023-12-13  5:53 [PATCH] Add keywords to TuiWindow.write Tom Tromey
@ 2023-12-30 19:22 ` Tom Tromey
  2023-12-31 19:57   ` Mark Wielaard
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-12-30 19:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> The gdb docs promise that methods with more than two or more arguments
Tom> will accept keywords.  However, I found that TuiWindow.write didn't
Tom> allow them.  This patch adds the missing support.

I'm checking this in.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add keywords to TuiWindow.write
  2023-12-30 19:22 ` Tom Tromey
@ 2023-12-31 19:57   ` Mark Wielaard
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2023-12-31 19:57 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Hi Tom,

On Sat, Dec 30, 2023 at 12:22:26PM -0700, Tom Tromey wrote:
> >>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
> 
> Tom> The gdb docs promise that methods with more than two or more arguments
> Tom> will accept keywords.  However, I found that TuiWindow.write didn't
> Tom> allow them.  This patch adds the missing support.
> 
> I'm checking this in.

This broke the python black checker:
https://builder.sourceware.org/buildbot/#/builders/74/builds/6022

--- /home/builder/shared/bb1-2/worker/gdb-fedora-x86_64/binutils-gdb/gdb/testsuite/gdb.python/tui-window.py	2023-12-30 19:45:58.307468+00:00
+++ /home/builder/shared/bb1-2/worker/gdb-fedora-x86_64/binutils-gdb/gdb/testsuite/gdb.python/tui-window.py	2023-12-30 19:51:54.065041+00:00
@@ -30,12 +30,14 @@
 
     def render(self):
         self.win.erase()
         w = self.win.width
         h = self.win.height
-        self.win.write(string="Test: " + str(self.count) + " " + str(w) + "x" + str(h),
-                       full_window=False)
+        self.win.write(
+            string="Test: " + str(self.count) + " " + str(w) + "x" + str(h),
+            full_window=False,
+        )
         self.count = self.count + 1
 
     # Tries to delete the title attribute.  GDB will throw an error.
     def remove_title(self):
         del self.win.title
would reformat /home/builder/shared/bb1-2/worker/gdb-fedora-x86_64/binutils-gdb/gdb/testsuite/gdb.python/tui-window.py
Oh no! 💥 💔 💥
1 file would be reformatted, 149 files would be left unchanged.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-31 19:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-13  5:53 [PATCH] Add keywords to TuiWindow.write Tom Tromey
2023-12-30 19:22 ` Tom Tromey
2023-12-31 19:57   ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).