]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* gdb.python/py-prettyprint.py (_iterator): Remove exception_flag
authorPaul Koning <pkoning@equallogic.com>
Tue, 11 Dec 2012 20:54:52 +0000 (20:54 +0000)
committerPaul Koning <pkoning@equallogic.com>
Tue, 11 Dec 2012 20:54:52 +0000 (20:54 +0000)
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.
* 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.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.python/py-prettyprint.py
gdb/testsuite/gdb.python/py-typeprint.exp
gdb/testsuite/gdb.python/python.exp

index 7bdf96341673119e11f3451fabbfa5e60878b2bb..0673bab304081c693383ded6a6d95fd3a09f4f02 100644 (file)
@@ -1,3 +1,17 @@
+2012-12-11  Paul Koning  <paul_koning@dell.com>
+
+       * 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. 
+       * 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.
+       
 2012-12-10  Paul Koning  <paul_koning@dell.com>
 
        * gdb.base/charset.exp: Change print syntax for Python 3
index 227046e10ef47d7dce765ccd10815492b6cb471a..bd0671f9cc5a8eac5fa55a1c20b58e82857f4fb2 100644 (file)
@@ -20,6 +20,14 @@ import re
 import gdb
 
 def _iterator (pointer, len):
+    start = pointer
+    end = pointer + len
+    while pointer != end:
+        yield ('[%d]' % int (pointer - start), pointer.dereference())
+        pointer += 1
+
+# Same as _iterator but can be told to raise an exception.
+def _iterator_except (pointer, len):
     start = pointer
     end = pointer + len
     while pointer != end:
@@ -49,23 +57,7 @@ class ContainerPrinter (object):
         return _iterator(self.val['elements'], self.val['len'])
 
 # Treats a container as array.
-class ArrayPrinter:
-    class _iterator:
-        def __init__ (self, pointer, len):
-            self.start = pointer
-            self.pointer = pointer
-            self.end = pointer + len
-
-        def __iter__(self):
-            return self
-
-        def next(self):
-            if self.pointer == self.end:
-                raise StopIteration
-            result = self.pointer
-            self.pointer = self.pointer + 1
-            return ('[%d]' % int (result - self.start), result.dereference())
-
+class ArrayPrinter (object):
     def __init__(self, val):
         self.val = val
 
@@ -73,7 +65,7 @@ class ArrayPrinter:
         return 'array %s with %d elements' % (self.val['name'], self.val['len'])
 
     def children(self):
-        return self._iterator(self.val['elements'], self.val['len'])
+        return _iterator(self.val['elements'], self.val['len'])
 
     def display_hint (self):
         return 'array'
@@ -90,7 +82,7 @@ class NoStringContainerPrinter (object):
         return None
 
     def children(self):
-        return _iterator(self.val['elements'], self.val['len'])
+        return _iterator_except (self.val['elements'], self.val['len'])
 
 class pp_s (object):
     def __init__(self, val):
index ef0705519ccde70e9270ad4b514e18162ae172fb..eca8ec9e7e2de17b72a8f23b69790528915d4d0c 100644 (file)
@@ -28,7 +28,7 @@ if { [skip_python_tests] } { continue }
 
 set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
 
-gdb_test_no_output "python execfile ('${remote_python_file}')"
+gdb_test_no_output "python exec (open ('${remote_python_file}').read ())"
 
 cp_test_ptype_class s "basic test" "class" "templ<string>" {
     { field public "T x;" }
index bf0bf144e675656c3c8ec089b0df24d49b2c4423..8cf93c1f7e478ae24d8a53d7726626f9da5e894f 100644 (file)
@@ -362,7 +362,7 @@ gdb_py_test_multiple "prompt substitution readline" \
   "end" ""
 
 gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
-    -re "Python Exception <(type 'exceptions.|class ')RuntimeError'> Python exception called.*" {
+    -re "Python Exception (exceptions.RuntimeError|<(type 'exceptions.|class ')RuntimeError'>) Python exception called.*" {
        pass "set hook"
     }
 }