Add more missing parentheses to Python calls to print
Commit Message
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
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!
@@ -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"
@@ -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"
@@ -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."
@@ -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
}