public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [rfc patch+7.11] gdb-gdb.py: SyntaxError: Missing parentheses in call to 'print'
@ 2016-02-22 15:56 Jan Kratochvil
  2016-02-22 16:12 ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2016-02-22 15:56 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 910 bytes --]

Hi,

after build GDB
	--with-python=/usr/bin/python3
and for example stripping ./gdb and running:
	./gdb -data-directory data-directory/ -iex "add-auto-load-safe-path $PWD/gdb-gdb.gdb" -iex "add-auto-load-safe-path $PWD/gdb-gdb.py" ./gdb 
I get:
	Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
	  File "/home/jkratoch/redhat/gdb-test-python3/gdb/gdb-gdb.py", line 91
	    print "Warning: Cannot find enum type_flag_value type."
								  ^
	SyntaxError: Missing parentheses in call to 'print'
	(top-gdb) q

The fix would be obvious:
	s/print \(".*"\)/print (\1)

But then I was curious I do not see the warning messsage anyway.
So I tried to append \n to that string but I still do not see the warning.
But I do not know why.  This patch is probably right and it could be checked
in as "obvious" but given the warning still is not seen who knows.


Jan

[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 1261 bytes --]

gdb/ChangeLog
2016-02-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb-gdb.py (class TypeFlagsPrinter): Use parentheses for print.

diff --git a/gdb/gdb-gdb.py b/gdb/gdb-gdb.py
index 4f3ac1c..9a12baf 100644
--- a/gdb/gdb-gdb.py
+++ b/gdb/gdb-gdb.py
@@ -88,14 +88,14 @@ class TypeFlagsPrinter:
         try:
             flags = gdb.lookup_type("enum type_flag_value")
         except:
-            print "Warning: Cannot find enum type_flag_value type."
-            print "         `struct type' pretty-printer will be degraded"
+            print("Warning: Cannot find enum type_flag_value type.")
+            print("         `struct type' pretty-printer will be degraded")
             return
         try:
             iflags = gdb.lookup_type("enum type_instance_flag_value")
         except:
-            print "Warning: Cannot find enum type_instance_flag_value type."
-            print "         `struct type' pretty-printer will be degraded"
+            print("Warning: Cannot find enum type_instance_flag_value type.")
+            print("         `struct type' pretty-printer will be degraded")
             return
         # Note: TYPE_FLAG_MIN is a duplicate of TYPE_FLAG_UNSIGNED,
         # so exclude it from the list we are building.

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

* Re: [rfc patch+7.11] gdb-gdb.py: SyntaxError: Missing parentheses in call to 'print'
  2016-02-22 15:56 [rfc patch+7.11] gdb-gdb.py: SyntaxError: Missing parentheses in call to 'print' Jan Kratochvil
@ 2016-02-22 16:12 ` Simon Marchi
  2016-02-22 16:20   ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2016-02-22 16:12 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches

On 16-02-22 10:56 AM, Jan Kratochvil wrote:
> Hi,
> 
> after build GDB
> 	--with-python=/usr/bin/python3
> and for example stripping ./gdb and running:
> 	./gdb -data-directory data-directory/ -iex "add-auto-load-safe-path $PWD/gdb-gdb.gdb" -iex "add-auto-load-safe-path $PWD/gdb-gdb.py" ./gdb 
> I get:
> 	Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
> 	  File "/home/jkratoch/redhat/gdb-test-python3/gdb/gdb-gdb.py", line 91
> 	    print "Warning: Cannot find enum type_flag_value type."
> 								  ^
> 	SyntaxError: Missing parentheses in call to 'print'
> 	(top-gdb) q
> 
> The fix would be obvious:
> 	s/print \(".*"\)/print (\1)
> 
> But then I was curious I do not see the warning messsage anyway.
> So I tried to append \n to that string but I still do not see the warning.
> But I do not know why.  This patch is probably right and it could be checked
> in as "obvious" but given the warning still is not seen who knows.

Are you sure that the execution really goes through that line?  When I run
this with Python 3:

if 1 == 2:
	print "Hello"
print("Goodbye")

I get:

  File "test.py", line 2
    print "Hello"
                ^
SyntaxError: Missing parentheses in call to 'print'

That means Python notices the error at parse time, not execution time.  It could
very well be that you don't see the warning because that line is not actually
executed.


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

* [commit] [rfc patch+7.11] gdb-gdb.py: SyntaxError: Missing parentheses in call to 'print'
  2016-02-22 16:12 ` Simon Marchi
@ 2016-02-22 16:20   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2016-02-22 16:20 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

On Mon, 22 Feb 2016 17:12:43 +0100, Simon Marchi wrote:
> That means Python notices the error at parse time, not execution time.  It could
> very well be that you don't see the warning because that line is not actually
> executed.

OK, you are right.  In fact I had such an idea and I did test it but I realize
now my test was flawed.

Therefore checked in as obvious.

The newlines may be still wrong there, not sure, but that is a different
bug+fix.

master:
	ac46107c5c781894e013b10cd9fb5c98a8393d26
7.11:
	3d58f8997229b9045899dd306a47a3c27d03a9fd


Thanks,
Jan

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

end of thread, other threads:[~2016-02-22 16:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-22 15:56 [rfc patch+7.11] gdb-gdb.py: SyntaxError: Missing parentheses in call to 'print' Jan Kratochvil
2016-02-22 16:12 ` Simon Marchi
2016-02-22 16:20   ` [commit] " Jan Kratochvil

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