bpo-32962: Backport python-gdb.py and test_gdb.py from master (GH-7726)
* bpo-32962: python-gdb catchs ValueError on read_var() (GH-7692)
python-gdb now catchs ValueError on read_var(): when Python has no
debug symbols for example.
(cherry picked from commit 019d33b7a447e78057842332fb5d3bad01922122)
* bpo-32962: python-gdb catchs UnicodeDecodeError (GH-7693)
python-gdb now catchs UnicodeDecodeError exceptions when calling
string().
(cherry picked from commit d22fc0bc7de7882da204abe50884bbde2da4f9e7)
bpo-29367: python-gdb.py now supports also method-wrapper
(wrapperobject) objects.
(cherry picked from commit 611083331d534481ca7956a376e38fb0e9ef3854)
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index dce3c5c..d49769e 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -3,13 +3,14 @@
# The code for testing gdb was adapted from similar work in Unladen Swallow's
# Lib/test/test_jit_gdb.py
+import locale
import os
import re
import subprocess
import sys
import sysconfig
+import textwrap
import unittest
-import sysconfig
from test import test_support
from test.test_support import run_unittest, findfile
@@ -863,7 +864,24 @@
breakpoint='time_gmtime',
cmds_after_breakpoint=['py-bt-full'],
)
- self.assertIn('#0 <built-in function gmtime', gdb_output)
+ self.assertIn('#1 <built-in function gmtime', gdb_output)
+
+ @unittest.skipIf(python_is_optimized(),
+ "Python was compiled with optimizations")
+ def test_wrapper_call(self):
+ cmd = textwrap.dedent('''
+ class MyList(list):
+ def __init__(self):
+ super(MyList, self).__init__() # wrapper_call()
+
+ print("first break point")
+ l = MyList()
+ ''')
+ # Verify with "py-bt":
+ gdb_output = self.get_stack_trace(cmd,
+ cmds_after_breakpoint=['break wrapper_call', 'continue', 'py-bt'])
+ self.assertRegexpMatches(gdb_output,
+ r"<method-wrapper u?'__init__' of MyList object at ")
class PyPrintTests(DebuggerTests):