public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add more missing parentheses to Python calls to print
@ 2014-11-26 18:34 Simon Marchi
  2014-11-27  8:32 ` Joel Brobecker
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Marchi @ 2014-11-26 18:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

I noticed that there are calls to Python's print outside the gdb.python
directory, so this patch adds those that I found were missing.  They were
found by grepping for "python print [^(]", so it's always possible that
I missed some others that use another pattern.

Parentheses are mandatory with Python 3 when calling print.

gdb/testsuite/ChangeLog:

	* gdb.ada/py_range.exp: Add missing parentheses.
	* gdb.dwarf2/symtab-producer.exp: Same.
	* gdb.gdb/python-interrupts.exp: Same.
	* gdb.gdb/python-selftest.exp: Same.
---
 gdb/testsuite/gdb.ada/py_range.exp           | 6 +++---
 gdb/testsuite/gdb.dwarf2/symtab-producer.exp | 4 ++--
 gdb/testsuite/gdb.gdb/python-interrupts.exp  | 2 +-
 gdb/testsuite/gdb.gdb/python-selftest.exp    | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/py_range.exp b/gdb/testsuite/gdb.ada/py_range.exp
index 3fa029a..3e4cc81 100644
--- a/gdb/testsuite/gdb.ada/py_range.exp
+++ b/gdb/testsuite/gdb.ada/py_range.exp
@@ -30,11 +30,11 @@ if { [skip_python_tests] } { continue }
 set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
 runto "foo.adb:$bp_location"
 
-gdb_test "python print int(gdb.parse_and_eval('sr'))" \
+gdb_test "python print (int(gdb.parse_and_eval('sr')))" \
          "48"
 
-gdb_test "python print int(gdb.parse_and_eval('si'))" \
+gdb_test "python print (int(gdb.parse_and_eval('si')))" \
          "740804"
 
-gdb_test "python print int(gdb.parse_and_eval('ir'))" \
+gdb_test "python print (int(gdb.parse_and_eval('ir')))" \
          "974"
diff --git a/gdb/testsuite/gdb.dwarf2/symtab-producer.exp b/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
index 57cf04c..2081cff 100644
--- a/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
+++ b/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
@@ -95,9 +95,9 @@ if { [skip_python_tests] } { continue }
 gdb_py_test_silent_cmd "python with_producer = gdb.lookup_global_symbol(\"with_producer\")" \
     "get with_producer symbol" 0
 
-gdb_test "python print with_producer.symtab.producer" "ACME Compiler Company"
+gdb_test "python print (with_producer.symtab.producer)" "ACME Compiler Company"
 
 gdb_py_test_silent_cmd "python without_producer = gdb.lookup_global_symbol(\"without_producer\")" \
     "get without_producer symbol" 0
 
-gdb_test "python print without_producer.symtab.producer" "None"
+gdb_test "python print (without_producer.symtab.producer)" "None"
diff --git a/gdb/testsuite/gdb.gdb/python-interrupts.exp b/gdb/testsuite/gdb.gdb/python-interrupts.exp
index a41fc0c..70a3aea 100644
--- a/gdb/testsuite/gdb.gdb/python-interrupts.exp
+++ b/gdb/testsuite/gdb.gdb/python-interrupts.exp
@@ -25,7 +25,7 @@ proc test_python_interrupts {} {
     }
 
     gdb_breakpoint set_active_ext_lang temporary
-    gdb_test "call catch_command_errors(execute_command, \"python print 5\", 0, RETURN_MASK_ALL)" \
+    gdb_test "call catch_command_errors(execute_command, \"python print (5)\", 0, RETURN_MASK_ALL)" \
 	"Temporary breakpoint.*silently stop."
     gdb_test "signal SIGINT" \
 	"KeyboardInterrupt.*Error while executing Python code."
diff --git a/gdb/testsuite/gdb.gdb/python-selftest.exp b/gdb/testsuite/gdb.gdb/python-selftest.exp
index 017fc38..efe8698 100644
--- a/gdb/testsuite/gdb.gdb/python-selftest.exp
+++ b/gdb/testsuite/gdb.gdb/python-selftest.exp
@@ -22,7 +22,7 @@ proc selftest_python {} {
     }
 
     gdb_test_no_output "set variable gdb_python_initialized = 0"
-    gdb_test "call catch_command_errors(execute_command, \"python print 5\", 0, RETURN_MASK_ALL)" \
+    gdb_test "call catch_command_errors(execute_command, \"python print (5)\", 0, RETURN_MASK_ALL)" \
 	"Python not initialized.* = 0"
     return 0
 }
-- 
2.1.3

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

* Re: [PATCH] Add more missing parentheses to Python calls to print
  2014-11-26 18:34 [PATCH] Add more missing parentheses to Python calls to print Simon Marchi
@ 2014-11-27  8:32 ` Joel Brobecker
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Brobecker @ 2014-11-27  8:32 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches

Hi Simon,

On Wed, Nov 26, 2014 at 01:33:53PM -0500, Simon Marchi wrote:
> I noticed that there are calls to Python's print outside the gdb.python
> directory, so this patch adds those that I found were missing.  They were
> found by grepping for "python print [^(]", so it's always possible that
> I missed some others that use another pattern.
> 
> Parentheses are mandatory with Python 3 when calling print.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.ada/py_range.exp: Add missing parentheses.
> 	* gdb.dwarf2/symtab-producer.exp: Same.
> 	* gdb.gdb/python-interrupts.exp: Same.
> 	* gdb.gdb/python-selftest.exp: Same.

This is pre-approved, but can you remove the space before
the opening parenthesis? Since "print" has become a function
in Python 3, and we try to follow the standard python style,
unlike our GNU Coding Style in C/C++, there should be no
space before the parenthesis.

Thank you!
-- 
Joel

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

end of thread, other threads:[~2014-11-27  8:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-26 18:34 [PATCH] Add more missing parentheses to Python calls to print Simon Marchi
2014-11-27  8:32 ` Joel Brobecker

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