Commit 7f7765ce authored by Martin v. Löwis's avatar Martin v. Löwis

Issue #8330: Fix expected output in test_gdb.

parent 98431789
...@@ -226,7 +226,9 @@ class PrettyPrintTests(DebuggerTests): ...@@ -226,7 +226,9 @@ class PrettyPrintTests(DebuggerTests):
# This will only work on wide-unicode builds: # This will only work on wide-unicode builds:
self.assertGdbRepr(unichr(0x1D121)) self.assertGdbRepr(unichr(0x1D121))
except ValueError, e: except ValueError, e:
if e.message != 'unichr() arg not in range(0x10000) (narrow Python build)': # We're probably on a narrow-unicode build; if we're seeing a
# different problem, then re-raise it:
if e.args != ('unichr() arg not in range(0x10000) (narrow Python build)',):
raise e raise e
def test_sets(self): def test_sets(self):
...@@ -321,7 +323,7 @@ print foo''') ...@@ -321,7 +323,7 @@ print foo''')
self.assertTrue(m, self.assertTrue(m,
msg='Unexpected new-style class rendering %r' % gdb_repr) msg='Unexpected new-style class rendering %r' % gdb_repr)
def assertSane(self, source, corruption, exp_type='unknown'): def assertSane(self, source, corruption, expvalue=None, exptype=None):
'''Run Python under gdb, corrupting variables in the inferior process '''Run Python under gdb, corrupting variables in the inferior process
immediately before taking a backtrace. immediately before taking a backtrace.
...@@ -335,9 +337,23 @@ print foo''') ...@@ -335,9 +337,23 @@ print foo''')
gdb_repr, gdb_output = \ gdb_repr, gdb_output = \
self.get_gdb_repr(source, self.get_gdb_repr(source,
cmds_after_breakpoint=cmds_after_breakpoint) cmds_after_breakpoint=cmds_after_breakpoint)
self.assertTrue(re.match('<%s at remote 0x[0-9a-f]+>' % exp_type,
gdb_repr), if expvalue:
'Unexpected gdb representation: %r\n%s' % \ if gdb_repr == repr(expvalue):
# gdb managed to print the value in spite of the corruption;
# this is good (see http://bugs.python.org/issue8330)
return
if exptype:
pattern = '<' + exptype + ' at remote 0x[0-9a-f]+>'
else:
# Match anything for the type name; 0xDEADBEEF could point to
# something arbitrary (see http://bugs.python.org/issue8330)
pattern = '<.* at remote 0x[0-9a-f]+>'
m = re.match(pattern, gdb_repr)
if not m:
self.fail('Unexpected gdb representation: %r\n%s' % \
(gdb_repr, gdb_output)) (gdb_repr, gdb_output))
def test_NULL_ptr(self): def test_NULL_ptr(self):
...@@ -358,18 +374,20 @@ print foo''') ...@@ -358,18 +374,20 @@ print foo''')
def test_corrupt_ob_type(self): def test_corrupt_ob_type(self):
'Ensure that a PyObject* with a corrupt ob_type is handled gracefully' 'Ensure that a PyObject* with a corrupt ob_type is handled gracefully'
self.assertSane('print 42', self.assertSane('print 42',
'set op->ob_type=0xDEADBEEF') 'set op->ob_type=0xDEADBEEF',
expvalue=42)
def test_corrupt_tp_flags(self): def test_corrupt_tp_flags(self):
'Ensure that a PyObject* with a type with corrupt tp_flags is handled' 'Ensure that a PyObject* with a type with corrupt tp_flags is handled'
self.assertSane('print 42', self.assertSane('print 42',
'set op->ob_type->tp_flags=0x0', 'set op->ob_type->tp_flags=0x0',
exp_type='int') expvalue=42)
def test_corrupt_tp_name(self): def test_corrupt_tp_name(self):
'Ensure that a PyObject* with a type with corrupt tp_name is handled' 'Ensure that a PyObject* with a type with corrupt tp_name is handled'
self.assertSane('print 42', self.assertSane('print 42',
'set op->ob_type->tp_name=0xDEADBEEF') 'set op->ob_type->tp_name=0xDEADBEEF',
expvalue=42)
def test_NULL_instance_dict(self): def test_NULL_instance_dict(self):
'Ensure that a PyInstanceObject with with a NULL in_dict is handled' 'Ensure that a PyInstanceObject with with a NULL in_dict is handled'
...@@ -380,7 +398,7 @@ foo = Foo() ...@@ -380,7 +398,7 @@ foo = Foo()
foo.an_int = 42 foo.an_int = 42
print foo''', print foo''',
'set ((PyInstanceObject*)op)->in_dict = 0', 'set ((PyInstanceObject*)op)->in_dict = 0',
exp_type='Foo') exptype='Foo')
def test_builtins_help(self): def test_builtins_help(self):
'Ensure that the new-style class _Helper in site.py can be handled' 'Ensure that the new-style class _Helper in site.py can be handled'
......
...@@ -15,6 +15,8 @@ Core and Builtins ...@@ -15,6 +15,8 @@ Core and Builtins
Library Library
------- -------
- Issue #8330: Fix expected output in test_gdb.
- Issue #8374: Update the internal alias table in the :mod:`locale` module - Issue #8374: Update the internal alias table in the :mod:`locale` module
to cover recent locale changes and additions. to cover recent locale changes and additions.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment