Add more missing parentheses to Python calls to print

Message ID 1417026833-781-1-git-send-email-simon.marchi@ericsson.com
State Superseded
Headers

Commit Message

Simon Marchi Nov. 26, 2014, 6:33 p.m. UTC
  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(-)
  

Comments

Joel Brobecker Nov. 27, 2014, 8:32 a.m. UTC | #1
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!
  

Patch

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
 }