public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 3/3] Fix prints in tests for Python 3
  2014-11-26  4:36 [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu() Simon Marchi
  2014-11-26  4:36 ` [PATCH 2/3] Fix Python help() test for Python 3 Simon Marchi
@ 2014-11-26  4:36 ` Simon Marchi
  2014-11-27  8:40   ` Joel Brobecker
  2014-11-27  9:00 ` [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu() Joel Brobecker
  2 siblings, 1 reply; 14+ messages in thread
From: Simon Marchi @ 2014-11-26  4:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: simon.marchi, Simon Marchi

Python 3's print requires to use parentheses, so this patch adds them where
they were missing.

gdb/testsuite/ChangeLog:

	* gdb.python/py-linetable.exp: Add parentheses to calls to print.
	* gdb.python/py-type.exp: Same.
	* gdb.python/py-value-cc.exp: Same.
	* gdb.python/py-value.exp: Same.
---
 gdb/testsuite/gdb.python/py-linetable.exp | 14 +++++++-------
 gdb/testsuite/gdb.python/py-type.exp      |  6 +++---
 gdb/testsuite/gdb.python/py-value-cc.exp  | 24 ++++++++++++------------
 gdb/testsuite/gdb.python/py-value.exp     |  2 +-
 4 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
index 682b5b7..351f380 100644
--- a/gdb/testsuite/gdb.python/py-linetable.exp
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -44,17 +44,17 @@ gdb_py_test_multiple "input simple command" \
   "python" "" \
   "def list_lines():" "" \
   "   for l in lt:" "" \
-  "     print 'L' +str(l.line)+' A '+hex(l.pc)" "" \
+  "     print ('L' + str(l.line) + ' A ' + hex(l.pc))" "" \
   "end" ""
 
 gdb_test "python list_lines()" \
     "L20 A $hex.*L21 A $hex.*L22 A $hex.*L24 A $hex.*L25 A $hex.*L40 A $hex.*L42 A $hex.*L44 A $hex.*L42 A $hex.*L46 A $hex.*" \
     "test linetable iterator addr"
-gdb_test "python print len(lt.line(42))" "2" \
+gdb_test "python print (len(lt.line(42)))" "2" \
     "Test length of a multiple pc line"
-gdb_test "python print len(lt.line(20))" "1" \
+gdb_test "python print (len(lt.line(20)))" "1" \
     "Test length of a single pc line"
-gdb_test "python print lt.line(1)" "None" \
+gdb_test "python print (lt.line(1))" "None" \
     "Test None returned for line with no pc"
 
 # Test gdb.Linetable.sourcelines ()
@@ -65,12 +65,12 @@ gdb_test "python print sorted(fset)" \
     "Test frozen set contains line numbers"
 
 # Test gdb.Linetable.has_line ()
-gdb_test "python print lt.has_line(20)" \
+gdb_test "python print (lt.has_line(20))" \
     "True.*" \
     "Test has_pcs at line 20"
-gdb_test "python print lt.has_line(44)" \
+gdb_test "python print (lt.has_line(44))" \
     "True.*" \
     "Test has_pcs at line 40"
-gdb_test "python print lt.has_line(10)" \
+gdb_test "python print (lt.has_line(10))" \
     "False.*" \
     "Test has_pcs at line 10"
diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp
index 6b61f48..921b0cd 100644
--- a/gdb/testsuite/gdb.python/py-type.exp
+++ b/gdb/testsuite/gdb.python/py-type.exp
@@ -89,10 +89,10 @@ proc test_fields {lang} {
     gdb_py_test_silent_cmd "python ss = gdb.parse_and_eval('ss')" "init ss" 1
     gdb_py_test_silent_cmd "python ss_fields = ss.type.fields()" \
       "get fields from ss.type" 1
-    gdb_test "python print len(ss_fields)" "2" "Check length of ss_fields"
-    gdb_test "python print ss_fields\[0\].name is None" "True" \
+    gdb_test "python print (len(ss_fields))" "2" "Check length of ss_fields"
+    gdb_test "python print (ss_fields\[0\].name is None)" "True" \
       "Check ss_fields\[0\].name"
-    gdb_test "python print ss_fields\[1\].name is None" "True" \
+    gdb_test "python print (ss_fields\[1\].name is None)" "True" \
       "Check ss_fields\[1\].name"
     # Regression test for
     # http://sourceware.org/bugzilla/show_bug.cgi?id=12070.
diff --git a/gdb/testsuite/gdb.python/py-value-cc.exp b/gdb/testsuite/gdb.python/py-value-cc.exp
index 949f04f..a965f5d 100644
--- a/gdb/testsuite/gdb.python/py-value-cc.exp
+++ b/gdb/testsuite/gdb.python/py-value-cc.exp
@@ -88,18 +88,18 @@ gdb_test "python print(b_td\[b_fields\[0\]\]\['a'\])" "100" \
 gdb_test "python print(u\[u_fields\[0\]\])" "99.*" "u's first field via field"
 gdb_test "python print(u\[u_fields\[1\]\])" "99.*" "u's second field via field"
 
-gdb_test "python print len(x_fields)" "2" "number for fields in u"
-gdb_test "python print x\[x_fields\[0\]\]\['x'\]" "101" "x.x via field"
-gdb_test "python print x\[x_fields\[1\]\]\['a'\]" "102" "x.a via field"
-gdb_test "python print x_ptr\[x_fields\[0\]\]\['x'\]" "101" "x_ptr->x via field"
-gdb_test "python print x_ptr\[x_fields\[1\]\]\['a'\]" "102" "x_ptr->a via field"
-gdb_test "python print xtd\[x_fields\[0\]\]\['x'\]" "101" "xtd->x via field"
-gdb_test "python print xtd\[x_fields\[1\]\]\['a'\]" "102" "xtd->a via field"
-
-gdb_test "python print len(uu_fields)" "2" "number of fields in uu"
-gdb_test "python print uu\[uu_fields\[0\]\]\['x'\]" "1000" "uu.x via field"
-gdb_test "python print uu\[uu_fields\[1\]\]\['a'\]" "1000" "uu.a via field"
+gdb_test "python print (len(x_fields))" "2" "number for fields in u"
+gdb_test "python print (x\[x_fields\[0\]\]\['x'\])" "101" "x.x via field"
+gdb_test "python print (x\[x_fields\[1\]\]\['a'\])" "102" "x.a via field"
+gdb_test "python print (x_ptr\[x_fields\[0\]\]\['x'\])" "101" "x_ptr->x via field"
+gdb_test "python print (x_ptr\[x_fields\[1\]\]\['a'\])" "102" "x_ptr->a via field"
+gdb_test "python print (xtd\[x_fields\[0\]\]\['x'\])" "101" "xtd->x via field"
+gdb_test "python print (xtd\[x_fields\[1\]\]\['a'\])" "102" "xtd->a via field"
+
+gdb_test "python print (len(uu_fields))" "2" "number of fields in uu"
+gdb_test "python print (uu\[uu_fields\[0\]\]\['x'\])" "1000" "uu.x via field"
+gdb_test "python print (uu\[uu_fields\[1\]\]\['a'\])" "1000" "uu.a via field"
 
 # Test overloaded operators.
 gdb_test_no_output "python a = gdb.parse_and_eval('a')" "init a"
-gdb_test "python print a + 5" "10" "a + 5"
+gdb_test "python print (a + 5)" "10" "a + 5"
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 0e1534a..76238a1 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -294,7 +294,7 @@ proc test_value_in_inferior {} {
   # Test fetching a string longer than its declared (in C) size.
   # PR 16286
   gdb_py_test_silent_cmd "python xstr = gdb.parse_and_eval('xstr')" "get xstr" 1
-  gdb_test "python print xstr\['text'\].string (length = xstr\['length'\])" "x{100}" \
+  gdb_test "python print (xstr\['text'\].string (length = xstr\['length'\]))" "x{100}" \
     "read string beyond declared size"
 }
 
-- 
2.1.3

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

* [PATCH 2/3] Fix Python help() test for Python 3
  2014-11-26  4:36 [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu() Simon Marchi
@ 2014-11-26  4:36 ` Simon Marchi
  2014-11-27  8:47   ` Joel Brobecker
  2014-11-26  4:36 ` [PATCH 3/3] Fix prints in tests " Simon Marchi
  2014-11-27  9:00 ` [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu() Joel Brobecker
  2 siblings, 1 reply; 14+ messages in thread
From: Simon Marchi @ 2014-11-26  4:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: simon.marchi, Simon Marchi

The message displayed when using help() changed a bit with time, so this
adjusts the test accordingly.

gdb/testsuite/ChangeLog:

	* gdb.python/python.exp: Change expected reply to help().
---
 gdb/testsuite/gdb.python/python.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index 787a294..7b4a5b8 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -67,7 +67,7 @@ gdb_py_test_multiple "multi-line python command" \
 with_test_prefix "python interactive help" {
     set test "python; help(); end"
     gdb_test_multiple "python\nhelp()\nend" $test {
-	-re "online help utility.*help> $" {
+	-re "Welcome to Python.*help utility.*help> $" {
 	    pass $test
 
 	    # The "quit" must be seen on the output.  A buggy GDB
-- 
2.1.3

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

* [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu()
@ 2014-11-26  4:36 Simon Marchi
  2014-11-26  4:36 ` [PATCH 2/3] Fix Python help() test for Python 3 Simon Marchi
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Simon Marchi @ 2014-11-26  4:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: simon.marchi, Simon Marchi

It seems like using os.getcwdu() here is wrong both for Python 2 and Python 3.

For Python 2, this returns a 'unicode' object, which tries to get concatenated
to a 'str' object in substitute_prompt. The implicit conversion works when the
unicode string contains no accent. When it does contain an accent though,
displaying the prompt results in the following error:

(gdb) set extended-prompt \w
...
  File "/home/simark/build/binutils-gdb-python2/gdb/data-directory/python/gdb/prompt.py", line 138, in substitute_prompt
    result += str(cmd(arg))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 49: ordinal not in range(128)

When using os.getcwd() instead, it works correctly. I suppose that Python does
the necessary decoding internally.

For Python 3, this method simply does not exist. It works fine with os.getcwd().

gdb/ChangeLog:

	* python/lib/gdb/prompt.py (_prompt_pwd): Use os.getcwd() instead of
	os.getcwdu().
---
 gdb/python/lib/gdb/prompt.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/python/lib/gdb/prompt.py b/gdb/python/lib/gdb/prompt.py
index d99f2ea..04adbfb 100644
--- a/gdb/python/lib/gdb/prompt.py
+++ b/gdb/python/lib/gdb/prompt.py
@@ -21,7 +21,7 @@ import os
 
 def _prompt_pwd(ignore):
     "The current working directory."
-    return os.getcwdu()
+    return os.getcwd()
 
 def _prompt_object_attr(func, what, attr, nattr):
     """Internal worker for fetching GDB attributes."""
-- 
2.1.3

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

* Re: [PATCH 3/3] Fix prints in tests for Python 3
  2014-11-26  4:36 ` [PATCH 3/3] Fix prints in tests " Simon Marchi
@ 2014-11-27  8:40   ` Joel Brobecker
  2014-11-28 16:40     ` Simon Marchi
  0 siblings, 1 reply; 14+ messages in thread
From: Joel Brobecker @ 2014-11-27  8:40 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches, simon.marchi

> Python 3's print requires to use parentheses, so this patch adds them where
> they were missing.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.python/py-linetable.exp: Add parentheses to calls to print.
> 	* gdb.python/py-type.exp: Same.
> 	* gdb.python/py-value-cc.exp: Same.
> 	* gdb.python/py-value.exp: Same.

Pre-approved with the same comment as before: Can you remove the space
between "print" and "(", please? You can push any other changes of this
nature under the "obvious" rule.

Thank you!

-- 
Joel

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

* Re: [PATCH 2/3] Fix Python help() test for Python 3
  2014-11-26  4:36 ` [PATCH 2/3] Fix Python help() test for Python 3 Simon Marchi
@ 2014-11-27  8:47   ` Joel Brobecker
  2014-11-28 15:57     ` Simon Marchi
  0 siblings, 1 reply; 14+ messages in thread
From: Joel Brobecker @ 2014-11-27  8:47 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches, simon.marchi

> The message displayed when using help() changed a bit with time, so this
> adjusts the test accordingly.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.python/python.exp: Change expected reply to help().

I am OK with the patch as is, and verified with Python 2.3, 2.6,
2.7 and 3.4 that "Welcome to Python" is part of the output of
the help() function. But since the purpose of the test is purely
to verify that the help() function does not hang, just verifying
that we have the prompt should achieve that goal, so I don't see
a need to extend the the expected output to match the "Welcome [...]"
message as well. I would personally just drop the "online" from
the expected output. Just my 2 cents, either way is fine.

Thank you!

> ---
>  gdb/testsuite/gdb.python/python.exp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
> index 787a294..7b4a5b8 100644
> --- a/gdb/testsuite/gdb.python/python.exp
> +++ b/gdb/testsuite/gdb.python/python.exp
> @@ -67,7 +67,7 @@ gdb_py_test_multiple "multi-line python command" \
>  with_test_prefix "python interactive help" {
>      set test "python; help(); end"
>      gdb_test_multiple "python\nhelp()\nend" $test {
> -	-re "online help utility.*help> $" {
> +	-re "Welcome to Python.*help utility.*help> $" {
>  	    pass $test
>  
>  	    # The "quit" must be seen on the output.  A buggy GDB
> -- 
> 2.1.3

-- 
Joel

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

* Re: [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu()
  2014-11-26  4:36 [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu() Simon Marchi
  2014-11-26  4:36 ` [PATCH 2/3] Fix Python help() test for Python 3 Simon Marchi
  2014-11-26  4:36 ` [PATCH 3/3] Fix prints in tests " Simon Marchi
@ 2014-11-27  9:00 ` Joel Brobecker
  2014-11-28 15:49   ` Simon Marchi
  2 siblings, 1 reply; 14+ messages in thread
From: Joel Brobecker @ 2014-11-27  9:00 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches, simon.marchi

> It seems like using os.getcwdu() here is wrong both for Python 2 and Python 3.
> 
> For Python 2, this returns a 'unicode' object, which tries to get concatenated
> to a 'str' object in substitute_prompt. The implicit conversion works when the
> unicode string contains no accent. When it does contain an accent though,
> displaying the prompt results in the following error:
> 
> (gdb) set extended-prompt \w
> ...
>   File "/home/simark/build/binutils-gdb-python2/gdb/data-directory/python/gdb/prompt.py", line 138, in substitute_prompt
>     result += str(cmd(arg))
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 49: ordinal not in range(128)
> 
> When using os.getcwd() instead, it works correctly. I suppose that Python does
> the necessary decoding internally.
> 
> For Python 3, this method simply does not exist. It works fine with os.getcwd().
> 
> gdb/ChangeLog:
> 
> 	* python/lib/gdb/prompt.py (_prompt_pwd): Use os.getcwd() instead of
> 	os.getcwdu().

I'd like to have other people's opinion on this, as I am not sure.

I _think_ that the patch is not making things worse for us,
while making things a little better in situations as the above.
So, based on that, I'd be inclined to apply it.

However, I think the long term fix would be, I believe, to switch
the entire thing to unicode. With Python3, it's automatic, but
with Python2, we might have to add 'u'-s on every piece of string
in the module, and also add some conversions here and there.
That's why I am thinking that the long term fix should be a blocker
for this patch.

Thoughts?

> ---
>  gdb/python/lib/gdb/prompt.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/python/lib/gdb/prompt.py b/gdb/python/lib/gdb/prompt.py
> index d99f2ea..04adbfb 100644
> --- a/gdb/python/lib/gdb/prompt.py
> +++ b/gdb/python/lib/gdb/prompt.py
> @@ -21,7 +21,7 @@ import os
>  
>  def _prompt_pwd(ignore):
>      "The current working directory."
> -    return os.getcwdu()
> +    return os.getcwd()
>  
>  def _prompt_object_attr(func, what, attr, nattr):
>      """Internal worker for fetching GDB attributes."""
> -- 
> 2.1.3

-- 
Joel

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

* Re: [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu()
  2014-11-27  9:00 ` [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu() Joel Brobecker
@ 2014-11-28 15:49   ` Simon Marchi
  2014-11-29 11:42     ` Joel Brobecker
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Marchi @ 2014-11-28 15:49 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, simon.marchi

> I'd like to have other people's opinion on this, as I am not sure.
> 
> I _think_ that the patch is not making things worse for us,
> while making things a little better in situations as the above.
> So, based on that, I'd be inclined to apply it.
> 
> However, I think the long term fix would be, I believe, to switch
> the entire thing to unicode. With Python3, it's automatic, but
> with Python2, we might have to add 'u'-s on every piece of string
> in the module, and also add some conversions here and there.
> That's why I am thinking that the long term fix should be a blocker
> for this patch.
>
> Thoughts?

An eventual switch to use unicode everywhere would certainly undo this
patch. However, I don't see the point in leaving the broken code as-is,
unless there are imminent plans to make that switch happen.

Simon

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

* Re: [PATCH 2/3] Fix Python help() test for Python 3
  2014-11-27  8:47   ` Joel Brobecker
@ 2014-11-28 15:57     ` Simon Marchi
  2014-11-29 11:42       ` Joel Brobecker
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Marchi @ 2014-11-28 15:57 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, simon.marchi

> I am OK with the patch as is, and verified with Python 2.3, 2.6,
> 2.7 and 3.4 that "Welcome to Python" is part of the output of
> the help() function. But since the purpose of the test is purely
> to verify that the help() function does not hang, just verifying
> that we have the prompt should achieve that goal, so I don't see
> a need to extend the the expected output to match the "Welcome [...]"
> message as well. I would personally just drop the "online" from
> the expected output. Just my 2 cents, either way is fine.
> 
> Thank you!

Sure, it's really not a life or death issue. Let's go with this then?

From 5deccafc1d5713d77fbc78c65711d6f6a6f87892 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Tue, 25 Nov 2014 22:56:12 -0500
Subject: [PATCH] Fix Python help() test for Python 3

The message displayed when using help() changed a bit with time, so this
adjusts the test accordingly.

gdb/testsuite/ChangeLog:

	* gdb.python/python.exp: Change expected reply to help().
---
 gdb/testsuite/gdb.python/python.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index 787a294..dcbc35c 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -67,7 +67,7 @@ gdb_py_test_multiple "multi-line python command" \
 with_test_prefix "python interactive help" {
     set test "python; help(); end"
     gdb_test_multiple "python\nhelp()\nend" $test {
-	-re "online help utility.*help> $" {
+	-re ".*help utility.*help> $" {
 	    pass $test

 	    # The "quit" must be seen on the output.  A buggy GDB
-- 
2.1.3

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

* Re: [PATCH 3/3] Fix prints in tests for Python 3
  2014-11-27  8:40   ` Joel Brobecker
@ 2014-11-28 16:40     ` Simon Marchi
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2014-11-28 16:40 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, simon.marchi

On 2014-11-27 03:40 AM, Joel Brobecker wrote:
>> Python 3's print requires to use parentheses, so this patch adds them where
>> they were missing.
>>
>> gdb/testsuite/ChangeLog:
>>
>> 	* gdb.python/py-linetable.exp: Add parentheses to calls to print.
>> 	* gdb.python/py-type.exp: Same.
>> 	* gdb.python/py-value-cc.exp: Same.
>> 	* gdb.python/py-value.exp: Same.
> 
> Pre-approved with the same comment as before: Can you remove the space
> between "print" and "(", please? You can push any other changes of this
> nature under the "obvious" rule.
> 
> Thank you!

Thanks. Since it's all the same, I merged this patch with the other, "Add more
missing parentheses to Python calls to print", removing the spaces as you
mentioned.

So it is pushed as such:

From 643bb4827e76bd8ac96abcb35db38e50ca2f97fd Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@ericsson.com>
Date: Fri, 28 Nov 2014 11:18:48 -0500
Subject: [PATCH] Fix prints in tests for Python 3

Python 3's print requires to use parentheses, so this patch adds them
where they were missing.

gdb/testsuite/ChangeLog:

	* gdb.ada/py_range.exp: Add parentheses to python calls to print.
	* gdb.dwarf2/symtab-producer.exp: Same.
	* gdb.gdb/python-interrupts.exp: Same.
	* gdb.gdb/python-selftest.exp: Same.
	* gdb.python/py-linetable.exp: Same.
	* gdb.python/py-type.exp: Same.
	* gdb.python/py-value-cc.exp: Same.
	* gdb.python/py-value.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 +-
 gdb/testsuite/gdb.python/py-linetable.exp    | 14 +++++++-------
 gdb/testsuite/gdb.python/py-type.exp         |  6 +++---
 gdb/testsuite/gdb.python/py-value-cc.exp     | 24 ++++++++++++------------
 gdb/testsuite/gdb.python/py-value.exp        |  2 +-
 8 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/py_range.exp b/gdb/testsuite/gdb.ada/py_range.exp
index 3fa029a..b35c4bf 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..58299f2 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..5a54801 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..77ac15a 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
 }
diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
index 2f24ab4..a3d5a75c 100644
--- a/gdb/testsuite/gdb.python/py-linetable.exp
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -44,17 +44,17 @@ gdb_py_test_multiple "input simple command" \
   "python" "" \
   "def list_lines():" "" \
   "   for l in lt:" "" \
-  "     print 'L' +str(l.line)+' A '+hex(l.pc)" "" \
+  "     print ('L' + str(l.line) + ' A ' + hex(l.pc))" "" \
   "end" ""

 gdb_test "python list_lines()" \
     "L20 A $hex.*L21 A $hex.*L22 A $hex.*L24 A $hex.*L25 A $hex.*L40 A $hex.*L42 A $hex.*L44 A $hex.*L42 A $hex.*L46 A $hex.*" \
     "test linetable iterator addr"
-gdb_test "python print len(lt.line(42))" "2" \
+gdb_test "python print(len(lt.line(42)))" "2" \
     "Test length of a multiple pc line"
-gdb_test "python print len(lt.line(20))" "1" \
+gdb_test "python print(len(lt.line(20)))" "1" \
     "Test length of a single pc line"
-gdb_test "python print lt.line(1)" "None" \
+gdb_test "python print(lt.line(1))" "None" \
     "Test None returned for line with no pc"

 # Test gdb.Linetable.sourcelines ()
@@ -65,12 +65,12 @@ gdb_test "python print (sorted(fset))" \
     "Test frozen set contains line numbers"

 # Test gdb.Linetable.has_line ()
-gdb_test "python print lt.has_line(20)" \
+gdb_test "python print(lt.has_line(20))" \
     "True.*" \
     "Test has_pcs at line 20"
-gdb_test "python print lt.has_line(44)" \
+gdb_test "python print(lt.has_line(44))" \
     "True.*" \
     "Test has_pcs at line 40"
-gdb_test "python print lt.has_line(10)" \
+gdb_test "python print(lt.has_line(10))" \
     "False.*" \
     "Test has_pcs at line 10"
diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp
index 6b61f48..ebf7798 100644
--- a/gdb/testsuite/gdb.python/py-type.exp
+++ b/gdb/testsuite/gdb.python/py-type.exp
@@ -89,10 +89,10 @@ proc test_fields {lang} {
     gdb_py_test_silent_cmd "python ss = gdb.parse_and_eval('ss')" "init ss" 1
     gdb_py_test_silent_cmd "python ss_fields = ss.type.fields()" \
       "get fields from ss.type" 1
-    gdb_test "python print len(ss_fields)" "2" "Check length of ss_fields"
-    gdb_test "python print ss_fields\[0\].name is None" "True" \
+    gdb_test "python print(len(ss_fields))" "2" "Check length of ss_fields"
+    gdb_test "python print(ss_fields\[0\].name is None)" "True" \
       "Check ss_fields\[0\].name"
-    gdb_test "python print ss_fields\[1\].name is None" "True" \
+    gdb_test "python print(ss_fields\[1\].name is None)" "True" \
       "Check ss_fields\[1\].name"
     # Regression test for
     # http://sourceware.org/bugzilla/show_bug.cgi?id=12070.
diff --git a/gdb/testsuite/gdb.python/py-value-cc.exp b/gdb/testsuite/gdb.python/py-value-cc.exp
index 949f04f..5f64275 100644
--- a/gdb/testsuite/gdb.python/py-value-cc.exp
+++ b/gdb/testsuite/gdb.python/py-value-cc.exp
@@ -88,18 +88,18 @@ gdb_test "python print(b_td\[b_fields\[0\]\]\['a'\])" "100" \
 gdb_test "python print(u\[u_fields\[0\]\])" "99.*" "u's first field via field"
 gdb_test "python print(u\[u_fields\[1\]\])" "99.*" "u's second field via field"

-gdb_test "python print len(x_fields)" "2" "number for fields in u"
-gdb_test "python print x\[x_fields\[0\]\]\['x'\]" "101" "x.x via field"
-gdb_test "python print x\[x_fields\[1\]\]\['a'\]" "102" "x.a via field"
-gdb_test "python print x_ptr\[x_fields\[0\]\]\['x'\]" "101" "x_ptr->x via field"
-gdb_test "python print x_ptr\[x_fields\[1\]\]\['a'\]" "102" "x_ptr->a via field"
-gdb_test "python print xtd\[x_fields\[0\]\]\['x'\]" "101" "xtd->x via field"
-gdb_test "python print xtd\[x_fields\[1\]\]\['a'\]" "102" "xtd->a via field"
-
-gdb_test "python print len(uu_fields)" "2" "number of fields in uu"
-gdb_test "python print uu\[uu_fields\[0\]\]\['x'\]" "1000" "uu.x via field"
-gdb_test "python print uu\[uu_fields\[1\]\]\['a'\]" "1000" "uu.a via field"
+gdb_test "python print(len(x_fields))" "2" "number for fields in u"
+gdb_test "python print(x\[x_fields\[0\]\]\['x'\])" "101" "x.x via field"
+gdb_test "python print(x\[x_fields\[1\]\]\['a'\])" "102" "x.a via field"
+gdb_test "python print(x_ptr\[x_fields\[0\]\]\['x'\])" "101" "x_ptr->x via field"
+gdb_test "python print(x_ptr\[x_fields\[1\]\]\['a'\])" "102" "x_ptr->a via field"
+gdb_test "python print(xtd\[x_fields\[0\]\]\['x'\])" "101" "xtd->x via field"
+gdb_test "python print(xtd\[x_fields\[1\]\]\['a'\])" "102" "xtd->a via field"
+
+gdb_test "python print(len(uu_fields))" "2" "number of fields in uu"
+gdb_test "python print(uu\[uu_fields\[0\]\]\['x'\])" "1000" "uu.x via field"
+gdb_test "python print(uu\[uu_fields\[1\]\]\['a'\])" "1000" "uu.a via field"

 # Test overloaded operators.
 gdb_test_no_output "python a = gdb.parse_and_eval('a')" "init a"
-gdb_test "python print a + 5" "10" "a + 5"
+gdb_test "python print(a + 5)" "10" "a + 5"
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 0e1534a..f081ff0 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -294,7 +294,7 @@ proc test_value_in_inferior {} {
   # Test fetching a string longer than its declared (in C) size.
   # PR 16286
   gdb_py_test_silent_cmd "python xstr = gdb.parse_and_eval('xstr')" "get xstr" 1
-  gdb_test "python print xstr\['text'\].string (length = xstr\['length'\])" "x{100}" \
+  gdb_test "python print(xstr\['text'\].string (length = xstr\['length'\]))" "x{100}" \
     "read string beyond declared size"
 }

-- 
2.1.3

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

* Re: [PATCH 2/3] Fix Python help() test for Python 3
  2014-11-28 15:57     ` Simon Marchi
@ 2014-11-29 11:42       ` Joel Brobecker
  2014-12-01 13:08         ` Simon Marchi
  0 siblings, 1 reply; 14+ messages in thread
From: Joel Brobecker @ 2014-11-29 11:42 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches, simon.marchi

> Sure, it's really not a life or death issue. Let's go with this then?
> 
> >From 5deccafc1d5713d77fbc78c65711d6f6a6f87892 Mon Sep 17 00:00:00 2001
> From: Simon Marchi <simon.marchi@ericsson.com>
> Date: Tue, 25 Nov 2014 22:56:12 -0500
> Subject: [PATCH] Fix Python help() test for Python 3
> 
> The message displayed when using help() changed a bit with time, so this
> adjusts the test accordingly.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.python/python.exp: Change expected reply to help().

Great! This is OK.

Thank you,
-- 
Joel

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

* Re: [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu()
  2014-11-28 15:49   ` Simon Marchi
@ 2014-11-29 11:42     ` Joel Brobecker
  2014-12-05 20:36       ` Simon Marchi
  0 siblings, 1 reply; 14+ messages in thread
From: Joel Brobecker @ 2014-11-29 11:42 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb-patches, simon.marchi

> > I'd like to have other people's opinion on this, as I am not sure.
> > 
> > I _think_ that the patch is not making things worse for us,
> > while making things a little better in situations as the above.
> > So, based on that, I'd be inclined to apply it.
> > 
> > However, I think the long term fix would be, I believe, to switch
> > the entire thing to unicode. With Python3, it's automatic, but
> > with Python2, we might have to add 'u'-s on every piece of string
> > in the module, and also add some conversions here and there.
> > That's why I am thinking that the long term fix should be a blocker
> > for this patch.
> >
> > Thoughts?
> 
> An eventual switch to use unicode everywhere would certainly undo this
> patch. However, I don't see the point in leaving the broken code as-is,
> unless there are imminent plans to make that switch happen.

That's exactly my thinking. But not being very familiar with this
area, and the handling of unicode, I would like to give others
an opportunity to jump in. Let's wait another week, and see if
we get additional feedback. If not, we'll push the patch.

-- 
Joel

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

* Re: [PATCH 2/3] Fix Python help() test for Python 3
  2014-11-29 11:42       ` Joel Brobecker
@ 2014-12-01 13:08         ` Simon Marchi
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2014-12-01 13:08 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, simon.marchi

On 2014-11-29 06:42 AM, Joel Brobecker wrote:
>> Sure, it's really not a life or death issue. Let's go with this then?
>>
>> >From 5deccafc1d5713d77fbc78c65711d6f6a6f87892 Mon Sep 17 00:00:00 2001
>> From: Simon Marchi <simon.marchi@ericsson.com>
>> Date: Tue, 25 Nov 2014 22:56:12 -0500
>> Subject: [PATCH] Fix Python help() test for Python 3
>>
>> The message displayed when using help() changed a bit with time, so this
>> adjusts the test accordingly.
>>
>> gdb/testsuite/ChangeLog:
>>
>> 	* gdb.python/python.exp: Change expected reply to help().
> 
> Great! This is OK.
> 
> Thank you,

Pushed!

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

* Re: [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu()
  2014-11-29 11:42     ` Joel Brobecker
@ 2014-12-05 20:36       ` Simon Marchi
  2014-12-15 16:41         ` Simon Marchi
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Marchi @ 2014-12-05 20:36 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, simon.marchi

On 2014-11-29 06:42 AM, Joel Brobecker wrote:
>>> I'd like to have other people's opinion on this, as I am not sure.
>>>
>>> I _think_ that the patch is not making things worse for us,
>>> while making things a little better in situations as the above.
>>> So, based on that, I'd be inclined to apply it.
>>>
>>> However, I think the long term fix would be, I believe, to switch
>>> the entire thing to unicode. With Python3, it's automatic, but
>>> with Python2, we might have to add 'u'-s on every piece of string
>>> in the module, and also add some conversions here and there.
>>> That's why I am thinking that the long term fix should be a blocker
>>> for this patch.
>>>
>>> Thoughts?
>>
>> An eventual switch to use unicode everywhere would certainly undo this
>> patch. However, I don't see the point in leaving the broken code as-is,
>> unless there are imminent plans to make that switch happen.
> 
> That's exactly my thinking. But not being very familiar with this
> area, and the handling of unicode, I would like to give others
> an opportunity to jump in. Let's wait another week, and see if
> we get additional feedback. If not, we'll push the patch.

All right, if nothing comes up about this, I'll push it Monday, first thing
in the morning, while eating my cereals.

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

* Re: [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu()
  2014-12-05 20:36       ` Simon Marchi
@ 2014-12-15 16:41         ` Simon Marchi
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2014-12-15 16:41 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches, simon.marchi

On 2014-12-05 03:36 PM, Simon Marchi wrote:
> On 2014-11-29 06:42 AM, Joel Brobecker wrote:
>>>> I'd like to have other people's opinion on this, as I am not sure.
>>>>
>>>> I _think_ that the patch is not making things worse for us,
>>>> while making things a little better in situations as the above.
>>>> So, based on that, I'd be inclined to apply it.
>>>>
>>>> However, I think the long term fix would be, I believe, to switch
>>>> the entire thing to unicode. With Python3, it's automatic, but
>>>> with Python2, we might have to add 'u'-s on every piece of string
>>>> in the module, and also add some conversions here and there.
>>>> That's why I am thinking that the long term fix should be a blocker
>>>> for this patch.
>>>>
>>>> Thoughts?
>>>
>>> An eventual switch to use unicode everywhere would certainly undo this
>>> patch. However, I don't see the point in leaving the broken code as-is,
>>> unless there are imminent plans to make that switch happen.
>>
>> That's exactly my thinking. But not being very familiar with this
>> area, and the handling of unicode, I would like to give others
>> an opportunity to jump in. Let's wait another week, and see if
>> we get additional feedback. If not, we'll push the patch.
> 
> All right, if nothing comes up about this, I'll push it Monday, first thing
> in the morning, while eating my cereals.

I just pushed this.

Thanks.

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

end of thread, other threads:[~2014-12-15 16:41 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-26  4:36 [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu() Simon Marchi
2014-11-26  4:36 ` [PATCH 2/3] Fix Python help() test for Python 3 Simon Marchi
2014-11-27  8:47   ` Joel Brobecker
2014-11-28 15:57     ` Simon Marchi
2014-11-29 11:42       ` Joel Brobecker
2014-12-01 13:08         ` Simon Marchi
2014-11-26  4:36 ` [PATCH 3/3] Fix prints in tests " Simon Marchi
2014-11-27  8:40   ` Joel Brobecker
2014-11-28 16:40     ` Simon Marchi
2014-11-27  9:00 ` [PATCH 1/3] python extended prompt: Use os.getcwd() instead of os.getcwdu() Joel Brobecker
2014-11-28 15:49   ` Simon Marchi
2014-11-29 11:42     ` Joel Brobecker
2014-12-05 20:36       ` Simon Marchi
2014-12-15 16:41         ` Simon Marchi

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