This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [rfc patch+7.11] gdb-gdb.py: SyntaxError: Missing parentheses in call to 'print'
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>, <gdb-patches at sourceware dot org>
- Date: Mon, 22 Feb 2016 11:12:43 -0500
- Subject: Re: [rfc patch+7.11] gdb-gdb.py: SyntaxError: Missing parentheses in call to 'print'
- Authentication-results: sourceware.org; auth=none
- References: <20160222155646 dot GA1869 at host1 dot jankratochvil dot net>
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.