From patchwork Wed Dec 13 05:53:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 82024 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 66BAD3857007 for ; Wed, 13 Dec 2023 05:53:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 856FA3858D39 for ; Wed, 13 Dec 2023 05:53:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 856FA3858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 856FA3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702446806; cv=none; b=YeOlMzecQbh4IuRTjttlKrMFEkMx2+SCZj+7FzQVvSBYFV30+yMAJQ7tw6sE7XIdMjw6p7O6nt++96ojeMYH1k8DPjDo/VJWvraidn7VPdEc1cXuZkVmq52fz9ypDp+HH8qjbsJofnc/Jw6IULXI8boJImAmwHU1dRixpPJ5vuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702446806; c=relaxed/simple; bh=Hy8mDqc69seYgDSRThSrgTQOO7uBa3x+SgaCucDihYQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=j8E+Es/52CgzeV7EspK6yh42S5iNfBB1mGB+hwLzStHQyPYGIccsBfga9mL/XbaLB4L2/hcBb7Snv+S7cHn/VGqBAywHl9RxSz8OlDGJH4kGWrjuCYre7+2WiNezymc/I14TWn6vZgyUyAeD1CR2EtOWRl1xRyf9bdrRzUqCf4g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id D6zBrfTNj6nOZDIBPrEmv8; Wed, 13 Dec 2023 05:53:24 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id DIBPrT9Ri8vT0DIBPrWqEm; Wed, 13 Dec 2023 05:53:23 +0000 X-Authority-Analysis: v=2.4 cv=ffi+dmcF c=1 sm=1 tr=0 ts=657946d3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=e2cXIFwxEfEA:10 a=Qbun_eYptAEA:10 a=AIU-GhnVQ1O_UwtcG94A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=rlI1Hg+SkYXdwpJ+QbH4raI+HLqbe1LdtDld1Tdg5IU=; b=WZFjgy29CEBnGfOcnXOSxdrhA2 kEJWLermN0/w7mQERUE/YlyVInL/mh7euI8sXeFbO2ju91oOaNL3Kl328QlphOOJ3+542zpjMKz8P BP9hoZ14B1VQ4TNchavJIQKOK; Received: from 71-211-161-25.hlrn.qwest.net ([71.211.161.25]:39228 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rDIBO-004GsT-2i; Tue, 12 Dec 2023 22:53:22 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Add keywords to TuiWindow.write Date: Tue, 12 Dec 2023 22:53:15 -0700 Message-ID: <20231213055315.824821-1-tom@tromey.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.161.25 X-Source-L: No X-Exim-ID: 1rDIBO-004GsT-2i X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-161-25.hlrn.qwest.net (localhost.localdomain) [71.211.161.25]:39228 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBGh3VURKP0cPhhDDiyifT1Olt0UL8qKEK/12pqjF7jE9HTMEELhVFBRl1gbkA/HVmDHgQADojlizFsFOBT26XeL3WvJwMw8vb94zFmdaXifjwdadfwz 70qde/sNVgfw7z2fu5fS7ei9ks95qNgoKF53COaG5yel9/HbDsqCxqYMsnGnL78ZPVga2oVmqBmJAtdhf4M00zOlbrLDr4WIoWs= X-Spam-Status: No, score=-3023.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org 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.