* 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.
This commit is contained in:
parent
8d2cc612e5
commit
2960a434c3
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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;" }
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue