public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/docs: add parentheses in Python examples using print
@ 2021-01-08  9:29 Marco Barisione
  2021-01-08 10:22 ` Eli Zaretskii
  2021-01-25 14:07 ` [PING][PATCH] " Marco Barisione
  0 siblings, 2 replies; 7+ messages in thread
From: Marco Barisione @ 2021-01-08  9:29 UTC (permalink / raw)
  To: gdb-patches

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


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

* Re: [PATCH] gdb/docs: add parentheses in Python examples using print
  2021-01-08  9:29 [PATCH] gdb/docs: add parentheses in Python examples using print Marco Barisione
@ 2021-01-08 10:22 ` Eli Zaretskii
  2021-01-08 14:04   ` Andrew Burgess
  2021-01-25 14:07 ` [PING][PATCH] " Marco Barisione
  1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2021-01-08 10:22 UTC (permalink / raw)
  To: Marco Barisione; +Cc: gdb-patches

> Date: Fri,  8 Jan 2021 09:29:35 +0000
> From: Marco Barisione via Gdb-patches <gdb-patches@sourceware.org>
> 
> This makes the examples work both in Python 2 and 3.
> 
> gdb/doc/ChangeLog:
> 
> 	* python.texi: Add parentheses to print statements/functions.

I'm okay with the changes, assuming that some Python person says it's
indeed correct from Python POV.

Thanks.

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

* Re: [PATCH] gdb/docs: add parentheses in Python examples using print
  2021-01-08 10:22 ` Eli Zaretskii
@ 2021-01-08 14:04   ` Andrew Burgess
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Burgess @ 2021-01-08 14:04 UTC (permalink / raw)
  To: Marco Barisione; +Cc: Eli Zaretskii, gdb-patches

* Eli Zaretskii via Gdb-patches <gdb-patches@sourceware.org> [2021-01-08 12:22:59 +0200]:

> > Date: Fri,  8 Jan 2021 09:29:35 +0000
> > From: Marco Barisione via Gdb-patches <gdb-patches@sourceware.org>
> > 
> > This makes the examples work both in Python 2 and 3.
> > 
> > gdb/doc/ChangeLog:
> > 
> > 	* python.texi: Add parentheses to print statements/functions.
> 
> I'm okay with the changes, assuming that some Python person says it's
> indeed correct from Python POV.

I'm no Python expert, but can confirm the updated code should work in
Python 2 and 3, while the original is 2 only.

This seems like a good change to me.

Thanks,
Andrew

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

* [PING][PATCH] gdb/docs: add parentheses in Python examples using print
  2021-01-08  9:29 [PATCH] gdb/docs: add parentheses in Python examples using print Marco Barisione
  2021-01-08 10:22 ` Eli Zaretskii
@ 2021-01-25 14:07 ` Marco Barisione
  2021-01-25 15:30   ` Simon Marchi
  2021-01-25 15:41   ` Eli Zaretskii
  1 sibling, 2 replies; 7+ messages in thread
From: Marco Barisione @ 2021-01-25 14:07 UTC (permalink / raw)
  To: gdb-patches

Ping.

On Fri, 8 Jan 2021 at 09:29, Marco Barisione <mbarisione@undo.io> 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
>

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

* Re: [PING][PATCH] gdb/docs: add parentheses in Python examples using print
  2021-01-25 14:07 ` [PING][PATCH] " Marco Barisione
@ 2021-01-25 15:30   ` Simon Marchi
  2021-01-25 15:41   ` Eli Zaretskii
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2021-01-25 15:30 UTC (permalink / raw)
  To: Marco Barisione, 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 <mbarisione@undo.io> 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
>>

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

* Re: [PING][PATCH] gdb/docs: add parentheses in Python examples using print
  2021-01-25 14:07 ` [PING][PATCH] " Marco Barisione
  2021-01-25 15:30   ` Simon Marchi
@ 2021-01-25 15:41   ` Eli Zaretskii
  2021-01-25 15:50     ` Marco Barisione
  1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2021-01-25 15:41 UTC (permalink / raw)
  To: Marco Barisione; +Cc: gdb-patches

> Date: Mon, 25 Jan 2021 14:07:44 +0000
> From: Marco Barisione via Gdb-patches <gdb-patches@sourceware.org>
> 
> Ping.

AFAIU, this patch was already approved.

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

* Re: [PING][PATCH] gdb/docs: add parentheses in Python examples using print
  2021-01-25 15:41   ` Eli Zaretskii
@ 2021-01-25 15:50     ` Marco Barisione
  0 siblings, 0 replies; 7+ messages in thread
From: Marco Barisione @ 2021-01-25 15:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On 25 Jan 2021, at 15:41, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Mon, 25 Jan 2021 14:07:44 +0000
>> From: Marco Barisione via Gdb-patches <gdb-patches@sourceware.org>
>> 
>> Ping.
> 
> AFAIU, this patch was already approved.

Sorry! You said you were waiting for some Python person and Andrew said
"I'm no Python expert” so I wrongly assumed you were still waiting for
more feedback.

-- 
Marco Barisione


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

end of thread, other threads:[~2021-01-25 15:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-08  9:29 [PATCH] gdb/docs: add parentheses in Python examples using print Marco Barisione
2021-01-08 10:22 ` Eli Zaretskii
2021-01-08 14:04   ` Andrew Burgess
2021-01-25 14:07 ` [PING][PATCH] " Marco Barisione
2021-01-25 15:30   ` Simon Marchi
2021-01-25 15:41   ` Eli Zaretskii
2021-01-25 15:50     ` Marco Barisione

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).