From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19977 invoked by alias); 11 Dec 2012 19:45:09 -0000 Received: (qmail 19954 invoked by uid 22791); 11 Dec 2012 19:45:08 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from ausxipps301.us.dell.com (HELO ausxipps301.us.dell.com) (143.166.148.223) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Dec 2012 19:45:02 +0000 X-LoopCount0: from 10.170.28.39 From: To: Subject: [RFA] A few more Python version related testsuite fixes Date: Tue, 11 Dec 2012 19:45:00 -0000 Message-ID: Content-Type: text/plain; charset="us-ascii" Content-ID: <866288220026DA4DB9DC669B1BEFE907@dell.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes 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 X-SW-Source: 2012-12/txt/msg00353.txt.bz2 Here are a few more testsuite changes to handle Python version differences.= =20 The _iterator_except changes in py-pretttyprint.py are needed because the t= ests in py-mi.exp intended for that forced exception flag to apply only to = the NoStringContainerPrinter class,=20 Ok to commit? paul testsuite/ChangeLog: 2012-12-11 Paul Koning * gdb.python/py-prettyprint.py (_iterator): Remove exception_flag exception. (_iterator_except): New function. (ArrayPrinter): Use _iterator function instead of local _iterator class for Python 3 compatibility. (NoStringContainerPrinter): Use _iterator_except instead of _iterator.=20 * gdb.python/py-typeprint.exp: Use exec(open(...).read()) instead of execfile for Python 3 compatibility. * gdb.python/python.exp: Handle Python 2.4 exception traceback format in error_prompt test. Index: gdb/testsuite/gdb.python/py-prettyprint.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-prettyprint.py,v retrieving revision 1.17 diff -u -r1.17 py-prettyprint.py --- gdb/testsuite/gdb.python/py-prettyprint.py 10 Dec 2012 21:22:21 -0000 1= .17 +++ gdb/testsuite/gdb.python/py-prettyprint.py 11 Dec 2012 19:24:46 -0000 @@ -23,6 +23,14 @@ start =3D pointer end =3D pointer + len while pointer !=3D end: + yield ('[%d]' % int (pointer - start), pointer.dereference()) + pointer +=3D 1 + +# Same as _iterator but can be told to raise an exception. +def _iterator_except (pointer, len): + start =3D pointer + end =3D pointer + len + while pointer !=3D end: if exception_flag: raise gdb.MemoryError ('hi bob') yield ('[%d]' % int (pointer - start), pointer.dereference()) @@ -49,23 +57,7 @@ return _iterator(self.val['elements'], self.val['len']) =20 # Treats a container as array. -class ArrayPrinter: - class _iterator: - def __init__ (self, pointer, len): - self.start =3D pointer - self.pointer =3D pointer - self.end =3D pointer + len - - def __iter__(self): - return self - - def next(self): - if self.pointer =3D=3D self.end: - raise StopIteration - result =3D self.pointer - self.pointer =3D self.pointer + 1 - return ('[%d]' % int (result - self.start), result.dereference= ()) - +class ArrayPrinter (object): def __init__(self, val): self.val =3D val =20 @@ -73,7 +65,7 @@ return 'array %s with %d elements' % (self.val['name'], self.val['= len']) =20 def children(self): - return self._iterator(self.val['elements'], self.val['len']) + return _iterator(self.val['elements'], self.val['len']) =20 def display_hint (self): return 'array' @@ -90,7 +82,7 @@ return None =20 def children(self): - return _iterator(self.val['elements'], self.val['len']) + return _iterator_except (self.val['elements'], self.val['len']) =20 class pp_s (object): def __init__(self, val): Index: gdb/testsuite/gdb.python/py-typeprint.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-typeprint.exp,v retrieving revision 1.1 diff -u -r1.1 py-typeprint.exp --- gdb/testsuite/gdb.python/py-typeprint.exp 12 Nov 2012 17:41:59 -0000 1.1 +++ gdb/testsuite/gdb.python/py-typeprint.exp 11 Dec 2012 19:24:46 -0000 @@ -28,7 +28,7 @@ =20 set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfil= e}.py] =20 -gdb_test_no_output "python execfile ('${remote_python_file}')" +gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" =20 cp_test_ptype_class s "basic test" "class" "templ" { { field public "T x;" } Index: gdb/testsuite/gdb.python/python.exp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/testsuite/gdb.python/python.exp,v retrieving revision 1.38 diff -u -r1.38 python.exp --- gdb/testsuite/gdb.python/python.exp 10 Dec 2012 21:22:21 -0000 1.38 +++ gdb/testsuite/gdb.python/python.exp 11 Dec 2012 19:24:46 -0000 @@ -362,7 +362,7 @@ "end" "" =20 gdb_test_multiple "python gdb.prompt_hook =3D error_prompt" "set the hook"= { - -re "Python Exception <(type 'exceptions.|class ')RuntimeError'> Pytho= n exception called.*" { + -re "Python Exception (exceptions.RuntimeError|<(type 'exceptions.|cla= ss ')RuntimeError'>) Python exception called.*" { pass "set hook" } }