From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4V4fOP4B8GiizzUAWB0awg (envelope-from ) for ; Wed, 15 Oct 2025 16:20:14 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=jeremybryant.net header.i=@jeremybryant.net header.a=rsa-sha256 header.s=key1 header.b=VK+sLAZe; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DC0451E047; Wed, 15 Oct 2025 16:20:14 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 92B741E047 for ; Wed, 15 Oct 2025 16:20:13 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0FA413858CB6 for ; Wed, 15 Oct 2025 20:20:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FA413858CB6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=jeremybryant.net header.i=@jeremybryant.net header.a=rsa-sha256 header.s=key1 header.b=VK+sLAZe Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [IPv6:2001:41d0:1004:224b::b9]) by sourceware.org (Postfix) with ESMTPS id 870383858D1E for ; Wed, 15 Oct 2025 20:19:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 870383858D1E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=jeremybryant.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jeremybryant.net ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 870383858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:41d0:1004:224b::b9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760559579; cv=none; b=MehC6wDmcgMv/DBhUjLjXwDpK6qozNZQKVNV0x0M7Svepjj3933f9bTYbkSQfrQOeiIWRSptde8KNzTMwq5pYvfDTwAmBusSJXpgW5jTZDdtLN6p4SeD0p1Kuyed0dmf0En/SGsKRYaxwUq7y9WydM4/5b7Y5y8xS7Gin7PWvFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760559579; c=relaxed/simple; bh=qu5KFHyMvCoTR3NKH/++o6I7iF6opbk+GFy4LOPdLI8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FJNEsTFaUOrorauHWJObJl9Eavs4ovVvULE2+0BBltb9wbYKcu3E4OERGGIuhrMrrH+LCWrMwSGA31FvJr9Qt3hBfLv+qB1PNTqNpQ9f2cZhd8H8xks/EfuZpqZgsqLU+HEwo35/YpahruMn5CRnbIKrNpv1wy6PTFjuXOf2NjM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 870383858D1E X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jeremybryant.net; s=key1; t=1760559578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LGsYP0fLyZl9elu00BUxYmSvI0iAtaQ7aGK6dLtjFvc=; b=VK+sLAZeZQ6BhNMDnCrnHTiZkq2pjz+3gLlqWAMMlv1WmcY0LPy5S+l8nzW5bgO6LXqQXX 56g03pptNwQkaW2zS4ion0y8MnVDinSdpnbW/OkTxbNbrUWLW/jZk0+ehAvlc+RsV8fnMj A72KgOOAjoPR3flqLYrgch4rVxU1wfP38xdJJUTY8vFnPHxv9e55fYZ3zfcOO5ZNhgT6pE nokXDlTHsNCsT5R3TzZ6ITMrxfBYT7bv1GL5Z0V9OyOXlQ7fhzEtF8stXN5sDmGDLZWW2O e6bCM3CXGtdhc+jlrtSaRCOOk91Y3g3eYYAFWPZpQD/95+HoigVVOJVMbxrI+Q== From: Jeremy Bryant To: Tom Tromey Cc: GDB Patches , Simon Marchi , Simon Marchi , Eli Zaretskii Subject: [PATCH v2] - Adapt to Python-3 print syntax In-Reply-To: <87jz0wth2c.fsf@tromey.com> (Tom Tromey's message of "Wed, 15 Oct 2025 07:44:59 -0600") References: <87frbl8724.fsf@jeremybryant.net> <87jz0wth2c.fsf@tromey.com> Date: Wed, 15 Oct 2025 21:19:33 +0100 Message-ID: <874irz9aui.fsf@jeremybryant.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT 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~public-inbox=simark.ca@sourceware.org --=-=-= Content-Type: text/plain Tom Tromey writes: >>>>>> "Jeremy" == Jeremy Bryant writes: > > Jeremy> This change adapts doc examples to Python 3 so they work on current > Jeremy> installations. > > Jeremy> python.texi uses a mixture of Python 3 and Python 2 print syntax, the > Jeremy> latter having been sunsetted several years ago. > > This looks reasonable but: > > Jeremy> -(@value{GDBP}) python print 23 > Jeremy> +(@value{GDBP}) python print(23) > > Here there's no space after the "print" -- which is standard Python > style, so seems fine; but... > > Jeremy> -print gdb.string_to_argv ("1 2\ \\\"3 '4 \"5' \"6 '7\"") > Jeremy> +print (gdb.string_to_argv ("1 2\ \\\"3 '4 \"5' \"6 '7\"")) > > ... here there's no space. There were a few like this and I wondered > why the discrepancy. > > Tom Thanks Tom, I've corrected the discrepancy and now all changes are consistent. See revised patch v2 inline below for critique and attached for completeness. In the course of this, I've also removed a pre-existing extraneous space. WDYT? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-doc-python.texi-Adapt-to-Python-3-print-syntax.patch >From 94dde31def1f9ce943819857a7205b3557276d33 Mon Sep 17 00:00:00 2001 From: Jeremy Bryant Date: Tue, 14 Oct 2025 22:55:39 +0100 Subject: [PATCH] * doc/python.texi : Adapt to Python 3 print syntax This change adapts the print syntax to Python 3. The documentation examples will then work on current installations. Python 2 was sunsetted in January 2020. --- gdb/doc/python.texi | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index ed113173667..9df2c58f210 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -76,7 +76,7 @@ If given an argument, the @code{python} command will evaluate the argument as a Python command. For example: @smallexample -(@value{GDBP}) python print 23 +(@value{GDBP}) python print(23) 23 @end smallexample @@ -88,7 +88,7 @@ containing @code{end}. For example: @smallexample (@value{GDBP}) python ->print 23 +>print(23) >end 23 @end smallexample @@ -756,7 +756,7 @@ depends on @code{set python print-stack} (@pxref{Python Commands}). Example: @smallexample -(@value{GDBP}) python print foo +(@value{GDBP}) python print(foo) Traceback (most recent call last): File "", line 1, in NameError: name 'foo' is not defined @@ -1945,7 +1945,7 @@ settings. During a @code{print} or other operation, the values will reflect any flags that are temporarily in effect. @smallexample -(gdb) python print (gdb.print_options ()['max_elements']) +(gdb) python print(gdb.print_options ()['max_elements']) 200 @end smallexample @end defun @@ -4652,7 +4652,7 @@ Arguments are separated by spaces and may be quoted. Example: @smallexample -print gdb.string_to_argv ("1 2\ \\\"3 '4 \"5' \"6 '7\"") +print(gdb.string_to_argv ("1 2\ \\\"3 '4 \"5' \"6 '7\"")) ['1', '2 "3', '4 "5', "6 '7"] @end smallexample @@ -5981,7 +5981,7 @@ Two @code{gdb.Frame} objects can be compared for equality with the @code{==} operator, like: @smallexample -(@value{GDBP}) python print gdb.newest_frame() == gdb.selected_frame () +(@value{GDBP}) python print(gdb.newest_frame() == gdb.selected_frame ()) True @end smallexample @@ -9129,7 +9129,7 @@ Then in gdb: (gdb) start (gdb) python import gdb.types (gdb) python foo_ref = gdb.parse_and_eval("foo_ref") -(gdb) python print gdb.types.get_basic_type(foo_ref.type) +(gdb) python print(gdb.types.get_basic_type(foo_ref.type)) int @end smallexample @@ -9162,9 +9162,9 @@ Then in @value{GDBN}: @smallexample (@value{GDBP}) python import gdb.types (@value{GDBP}) python struct_a = gdb.lookup_type("struct A") -(@value{GDBP}) python print struct_a.keys () +(@value{GDBP}) python print(struct_a.keys ()) @{['a', '']@} -(@value{GDBP}) python print [k for k,v in gdb.types.deep_items(struct_a)] +(@value{GDBP}) python print([k for k,v in gdb.types.deep_items(struct_a)]) @{['a', 'b0', 'b1']@} @end smallexample -- 2.47.2 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-doc-python.texi-Adapt-to-Python-3-print-syntax.patch >From 94dde31def1f9ce943819857a7205b3557276d33 Mon Sep 17 00:00:00 2001 From: Jeremy Bryant Date: Tue, 14 Oct 2025 22:55:39 +0100 Subject: [PATCH] * doc/python.texi : Adapt to Python 3 print syntax This change adapts the print syntax to Python 3. The documentation examples will then work on current installations. Python 2 was sunsetted in January 2020. --- gdb/doc/python.texi | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index ed113173667..9df2c58f210 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -76,7 +76,7 @@ If given an argument, the @code{python} command will evaluate the argument as a Python command. For example: @smallexample -(@value{GDBP}) python print 23 +(@value{GDBP}) python print(23) 23 @end smallexample @@ -88,7 +88,7 @@ containing @code{end}. For example: @smallexample (@value{GDBP}) python ->print 23 +>print(23) >end 23 @end smallexample @@ -756,7 +756,7 @@ depends on @code{set python print-stack} (@pxref{Python Commands}). Example: @smallexample -(@value{GDBP}) python print foo +(@value{GDBP}) python print(foo) Traceback (most recent call last): File "", line 1, in NameError: name 'foo' is not defined @@ -1945,7 +1945,7 @@ settings. During a @code{print} or other operation, the values will reflect any flags that are temporarily in effect. @smallexample -(gdb) python print (gdb.print_options ()['max_elements']) +(gdb) python print(gdb.print_options ()['max_elements']) 200 @end smallexample @end defun @@ -4652,7 +4652,7 @@ Arguments are separated by spaces and may be quoted. Example: @smallexample -print gdb.string_to_argv ("1 2\ \\\"3 '4 \"5' \"6 '7\"") +print(gdb.string_to_argv ("1 2\ \\\"3 '4 \"5' \"6 '7\"")) ['1', '2 "3', '4 "5', "6 '7"] @end smallexample @@ -5981,7 +5981,7 @@ Two @code{gdb.Frame} objects can be compared for equality with the @code{==} operator, like: @smallexample -(@value{GDBP}) python print gdb.newest_frame() == gdb.selected_frame () +(@value{GDBP}) python print(gdb.newest_frame() == gdb.selected_frame ()) True @end smallexample @@ -9129,7 +9129,7 @@ Then in gdb: (gdb) start (gdb) python import gdb.types (gdb) python foo_ref = gdb.parse_and_eval("foo_ref") -(gdb) python print gdb.types.get_basic_type(foo_ref.type) +(gdb) python print(gdb.types.get_basic_type(foo_ref.type)) int @end smallexample @@ -9162,9 +9162,9 @@ Then in @value{GDBN}: @smallexample (@value{GDBP}) python import gdb.types (@value{GDBP}) python struct_a = gdb.lookup_type("struct A") -(@value{GDBP}) python print struct_a.keys () +(@value{GDBP}) python print(struct_a.keys ()) @{['a', '']@} -(@value{GDBP}) python print [k for k,v in gdb.types.deep_items(struct_a)] +(@value{GDBP}) python print([k for k,v in gdb.types.deep_items(struct_a)]) @{['a', 'b0', 'b1']@} @end smallexample -- 2.47.2 --=-=-=--