From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 87215 invoked by alias); 15 Apr 2015 15:27:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 87185 invoked by uid 89); 15 Apr 2015 15:27:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 15 Apr 2015 15:26:58 +0000 Received: from EUSAAHC006.ericsson.se (Unknown_Domain [147.117.188.90]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id A2.B4.17241.A302E255; Wed, 15 Apr 2015 10:24:26 +0200 (CEST) Received: from [142.133.110.232] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.92) with Microsoft SMTP Server id 14.3.210.2; Wed, 15 Apr 2015 11:26:55 -0400 Message-ID: <552E833F.50706@ericsson.com> Date: Wed, 15 Apr 2015 15:27:00 -0000 From: Simon Marchi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: gdb-patches Subject: Re: [PATCH] Some Python 3 fixes References: <1428426786-7704-1-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1428426786-7704-1-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-04/txt/msg00571.txt.bz2 On 15-04-07 01:13 PM, Simon Marchi wrote: > Some missing parentheses and one itertools.imap (Py2) vs map (Py3) issue. > > gdb/ChangeLog: > > * python/lib/gdb/command/unwinders.py: Add parentheses. > > gdb/testsuite/ChangeLog: > > * gdb.python/py-framefilter.py (ErrorFilter.filter): Use map function > if itertools.imap is not present. > * gdb.python/py-objfile.exp: Add parentheses. > * gdb.python/py-type.exp: Same. > * gdb.python/py-unwind-maint.py: Same. > --- > gdb/python/lib/gdb/command/unwinders.py | 2 +- > gdb/testsuite/gdb.python/py-framefilter.py | 7 ++++++- > gdb/testsuite/gdb.python/py-objfile.exp | 4 ++-- > gdb/testsuite/gdb.python/py-type.exp | 4 ++-- > gdb/testsuite/gdb.python/py-unwind-maint.py | 8 ++++---- > 5 files changed, 15 insertions(+), 10 deletions(-) > > diff --git a/gdb/python/lib/gdb/command/unwinders.py b/gdb/python/lib/gdb/command/unwinders.py > index 8530b35..1a5aed9 100644 > --- a/gdb/python/lib/gdb/command/unwinders.py > +++ b/gdb/python/lib/gdb/command/unwinders.py > @@ -83,7 +83,7 @@ class InfoUnwinder(gdb.Command): > """ > if not unwinders: > return > - print title > + print(title) > for unwinder in unwinders: > if name_re.match(unwinder.name): > print(" %s%s" % (unwinder.name, > diff --git a/gdb/testsuite/gdb.python/py-framefilter.py b/gdb/testsuite/gdb.python/py-framefilter.py > index 0de026c..1e5b2b3 100644 > --- a/gdb/testsuite/gdb.python/py-framefilter.py > +++ b/gdb/testsuite/gdb.python/py-framefilter.py > @@ -145,7 +145,12 @@ class ErrorFilter(): > gdb.frame_filters [self.name] = self > > def filter(self, frame_iter): > - return itertools.imap(ErrorInName, frame_iter) > + # Python 3.x moved the itertools.imap functionality to map(), > + # so check if it is available. > + if hasattr(itertools, "imap"): > + return itertools.imap (ErrorInName, frame_iter) > + else: > + return map(ErrorInName, frame_iter) > > FrameFilter() > FrameElider() > diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp > index b53f5e3..4de20c5 100644 > --- a/gdb/testsuite/gdb.python/py-objfile.exp > +++ b/gdb/testsuite/gdb.python/py-objfile.exp > @@ -88,9 +88,9 @@ if { [gdb_unload] < 0 } { > return -1 > } > > -gdb_test "python print objfile.filename" "None" \ > +gdb_test "python print(objfile.filename)" "None" \ > "objfile.filename after objfile is unloaded" > -gdb_test "python print objfile.username" "None" \ > +gdb_test "python print(objfile.username)" "None" \ > "objfile.username after objfile is unloaded" > > # Now build another copy of the testcase, this time without debug info. > diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp > index c4c8d9f..9e522f2 100644 > --- a/gdb/testsuite/gdb.python/py-type.exp > +++ b/gdb/testsuite/gdb.python/py-type.exp > @@ -247,10 +247,10 @@ restart_gdb "${binfile}" > # Skip all tests if Python scripting is not enabled. > if { [skip_python_tests] } { continue } > > -gdb_test "python print gdb.lookup_type('char').array(1, 0)" \ > +gdb_test "python print(gdb.lookup_type('char').array(1, 0))" \ > "char \\\[0\\\]" > > -gdb_test "python print gdb.lookup_type('char').array(1, -1)" \ > +gdb_test "python print(gdb.lookup_type('char').array(1, -1))" \ > "Array length must not be negative.*" > > with_test_prefix "lang_c" { > diff --git a/gdb/testsuite/gdb.python/py-unwind-maint.py b/gdb/testsuite/gdb.python/py-unwind-maint.py > index f8c6277..288fe07 100644 > --- a/gdb/testsuite/gdb.python/py-unwind-maint.py > +++ b/gdb/testsuite/gdb.python/py-unwind-maint.py > @@ -24,7 +24,7 @@ class TestGlobalUnwinder(Unwinder): > super(TestGlobalUnwinder, self).__init__("global_unwinder") > > def __call__(self, unwinder_info): > - print "%s called" % self.name > + print("%s called" % self.name) > return None > > class TestProgspaceUnwinder(Unwinder): > @@ -32,7 +32,7 @@ class TestProgspaceUnwinder(Unwinder): > super(TestProgspaceUnwinder, self).__init__("%s_ps_unwinder" % name) > > def __call__(self, unwinder_info): > - print "%s called" % self.name > + print("%s called" % self.name) > return None > > class TestObjfileUnwinder(Unwinder): > @@ -40,7 +40,7 @@ class TestObjfileUnwinder(Unwinder): > super(TestObjfileUnwinder, self).__init__("%s_obj_unwinder" % name) > > def __call__(self, unwinder_info): > - print "%s called" % self.name > + print("%s called" % self.name) > return None > > > @@ -56,4 +56,4 @@ if not saw_runtime_error: > gdb.unwinder.register_unwinder(None, TestGlobalUnwinder(), replace=True) > gdb.unwinder.register_unwinder(gdb.current_progspace(), > TestProgspaceUnwinder("py_unwind_maint")) > -print "Python script imported" > +print("Python script imported") > Ping!