From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 44alLSPkDmDbBQAAWB0awg (envelope-from ) for ; Mon, 25 Jan 2021 10:30:43 -0500 Received: by simark.ca (Postfix, from userid 112) id ADD631EF80; Mon, 25 Jan 2021 10:30:43 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 521601E945 for ; Mon, 25 Jan 2021 10:30:43 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F2F6E39C0BAE; Mon, 25 Jan 2021 15:30:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F2F6E39C0BAE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611588643; bh=FppElrteRWkvMceZDXwYs3eKgxA7yjjgwfFUlk77Y8Q=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=GCDKhycIWloyxLDS1zD82KPpxj+YveySillduXyDN8lmsc/0nCIlNjt1MRmw6oFwF HrhgTI6bMznQRQ+ddcH5lLjLiszG29bPLOxFvF//Xe6Qoe9IG6qxGmSYcR1mn9sSZC PUAXl17P9QG+djyWLgNgLGSkfESQyCN0hx7MjUaM= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id E285C3861875 for ; Mon, 25 Jan 2021 15:30:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E285C3861875 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 10PFUZqs015496 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Jan 2021 10:30:39 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 10PFUZqs015496 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 0A3211E945; Mon, 25 Jan 2021 10:30:35 -0500 (EST) Subject: Re: [PING][PATCH] gdb/docs: add parentheses in Python examples using print To: Marco Barisione , gdb-patches@sourceware.org References: <20210108092935.92106-1-mbarisione@undo.io> Message-ID: <775acd49-35a6-6ff6-a72c-ba191b081ebb@polymtl.ca> Date: Mon, 25 Jan 2021 10:30:34 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 25 Jan 2021 15:30:35 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" I think we were just missing for someone to push the patch, so I did it. Simon On 2021-01-25 9:07 a.m., Marco Barisione via Gdb-patches wrote: > Ping. > > On Fri, 8 Jan 2021 at 09:29, Marco Barisione wrote: >> >> This makes the examples work both in Python 2 and 3. >> >> gdb/doc/ChangeLog: >> >> * python.texi: Add parentheses to print statements/functions. >> --- >> 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 0f776f54768..da81906d03d 100644 >> --- a/gdb/doc/python.texi >> +++ b/gdb/doc/python.texi >> @@ -559,7 +559,7 @@ rather recognizes it when thrown from user Python code. Example: >> > argv = gdb.string_to_argv (args) >> > if len (argv) != 0: >> > raise gdb.GdbError ("hello-world takes no arguments") >> -> print "Hello, World!" >> +> print ("Hello, World!") >> >HelloWorld () >> >end >> (gdb) hello-world 42 >> @@ -3100,8 +3100,8 @@ Here is an example: >> >> @smallexample >> def exit_handler (event): >> - print "event type: exit" >> - print "exit code: %d" % (event.exit_code) >> + print ("event type: exit") >> + print ("exit code: %d" % (event.exit_code)) >> >> gdb.events.exited.connect (exit_handler) >> @end smallexample >> @@ -3921,7 +3921,7 @@ class HelloWorld (gdb.Command): >> super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_USER) >> >> def invoke (self, arg, from_tty): >> - print "Hello, World!" >> + print ("Hello, World!") >> >> HelloWorld () >> @end smallexample >> @@ -4309,7 +4309,7 @@ def clear_objfiles_handler(event): >> event.progspace.expensive_computation = None >> def expensive(symbol): >> """A mock routine to perform an "expensive" computation on symbol.""" >> - print "Computing the answer to the ultimate question ..." >> + print ("Computing the answer to the ultimate question ...") >> return 42 >> def new_objfile_handler(event): >> objfile = event.new_objfile >> @@ -4654,7 +4654,7 @@ versions. Using it, you could write: >> reason = gdb.selected_frame().unwind_stop_reason () >> reason_str = gdb.frame_stop_reason_string (reason) >> if reason >= gdb.FRAME_UNWIND_FIRST_ERROR: >> - print "An error occured: %s" % reason_str >> + print ("An error occured: %s" % reason_str) >> @end smallexample >> @end table >> >> @@ -5295,7 +5295,7 @@ example illustrating iterating over a line table. >> symtab = gdb.selected_frame().find_sal().symtab >> linetable = symtab.linetable() >> for line in linetable: >> - print "Line: "+str(line.line)+" Address: "+hex(line.pc) >> + print ("Line: "+str(line.line)+" Address: "+hex(line.pc)) >> @end smallexample >> >> This will have the following output: >> @@ -5618,11 +5618,11 @@ method: >> @smallexample >> class MyFinishBreakpoint (gdb.FinishBreakpoint) >> def stop (self): >> - print "normal finish" >> + print ("normal finish") >> return True >> >> def out_of_scope (): >> - print "abnormal finish" >> + print ("abnormal finish") >> @end smallexample >> @end defun >> >> -- >> 2.28.0 >>