[Python-checkins] r80311 - in python/branches/py3k: Lib/test/test_gdb.py Tools/gdb/libpython.py

victor.stinner python-checkins at python.org
Wed Apr 21 15:53:05 CEST 2010


Author: victor.stinner
Date: Wed Apr 21 15:53:05 2010
New Revision: 80311

Log:
Adapt libpython.py and test_gdb.py to Python3

 * Rename PyStringObjectPtr to PyBytesObjectPtr
 * Replace PyObject_Print by textiowrapper_write


Modified:
   python/branches/py3k/Lib/test/test_gdb.py
   python/branches/py3k/Tools/gdb/libpython.py

Modified: python/branches/py3k/Lib/test/test_gdb.py
==============================================================================
--- python/branches/py3k/Lib/test/test_gdb.py	(original)
+++ python/branches/py3k/Lib/test/test_gdb.py	Wed Apr 21 15:53:05 2010
@@ -60,7 +60,7 @@
         return out.decode('iso-8859-1'), err.decode('iso-8859-1')
 
     def get_stack_trace(self, source=None, script=None,
-                        breakpoint='PyObject_Print',
+                        breakpoint='textiowrapper_write',
                         cmds_after_breakpoint=None,
                         import_site=False):
         '''
@@ -78,7 +78,7 @@
         # error, which typically happens python is dynamically linked (the
         # breakpoints of interest are to be found in the shared library)
         # When this happens, we still get:
-        #   Function "PyObject_Print" not defined.
+        #   Function "textiowrapper_write" not defined.
         # emitted to stderr each time, alas.
 
         # Initially I had "--eval-command=continue" here, but removed it to
@@ -130,18 +130,18 @@
                      import_site=False):
         # Given an input python source representation of data,
         # run "python -c'print DATA'" under gdb with a breakpoint on
-        # PyObject_Print and scrape out gdb's representation of the "op"
+        # textiowrapper_write and scrape out gdb's representation of the "op"
         # parameter, and verify that the gdb displays the same string
         #
         # For a nested structure, the first time we hit the breakpoint will
         # give us the top-level structure
-        gdb_output = self.get_stack_trace(source, breakpoint='PyObject_Print',
+        gdb_output = self.get_stack_trace(source, breakpoint='textiowrapper_write',
                                           cmds_after_breakpoint=cmds_after_breakpoint,
                                           import_site=import_site)
         # gdb can insert additional '\n' and space characters in various places
         # in its output, depending on the width of the terminal it's connected
         # to (using its "wrap_here" function)
-        m = re.match('.*#0\s+PyObject_Print\s+\(\s*op\=\s*(.*?),\s+fp=.*\).*',
+        m = re.match('.*#0\s+textiowrapper_write\s+\(\s*op\=\s*(.*?),\s+fp=.*\).*',
                      gdb_output, re.DOTALL)
         if not m:
             self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output))
@@ -163,7 +163,7 @@
 class PrettyPrintTests(DebuggerTests):
     def test_getting_backtrace(self):
         gdb_output = self.get_stack_trace('print(42)')
-        self.assertTrue('PyObject_Print' in gdb_output)
+        self.assertTrue('textiowrapper_write' in gdb_output)
 
     def assertGdbRepr(self, val, cmds_after_breakpoint=None):
         # Ensure that gdb's rendering of the value in a debugged process
@@ -533,7 +533,7 @@
 
 foo(3, 4, 5)
 print foo.__code__''',
-                                          breakpoint='PyObject_Print',
+                                          breakpoint='textiowrapper_write',
                                           cmds_after_breakpoint=['print (PyFrameObject*)(((PyCodeObject*)op)->co_zombieframe)']
                                           )
         self.assertTrue(re.match(r'.*\s+\$1 =\s+Frame 0x[0-9a-f]+, for file <string>, line 3, in foo \(\)\s+.*',

Modified: python/branches/py3k/Tools/gdb/libpython.py
==============================================================================
--- python/branches/py3k/Tools/gdb/libpython.py	(original)
+++ python/branches/py3k/Tools/gdb/libpython.py	Wed Apr 21 15:53:05 2010
@@ -19,7 +19,7 @@
 In particular, given a gdb.Value corresponding to a PyObject* in the inferior
 process, we can generate a "proxy value" within the gdb process.  For example,
 given a PyObject* in the inferior process that is in fact a PyListObject*
-holding three PyObject* that turn out to be PyStringObject* instances, we can
+holding three PyObject* that turn out to be PyBytesObject* instances, we can
 generate a proxy value within the gdb process that is a list of strings:
   ["foo", "bar", "baz"]
 
@@ -108,7 +108,7 @@
 class PyObjectPtr(object):
     """
     Class wrapping a gdb.Value that's a either a (PyObject*) within the
-    inferior process, or some subclass pointer e.g. (PyStringObject*)
+    inferior process, or some subclass pointer e.g. (PyBytesObject*)
 
     There will be a subclass for every refined PyObject type that we care
     about.
@@ -319,7 +319,7 @@
         if tp_flags & Py_TPFLAGS_TUPLE_SUBCLASS:
             return PyTupleObjectPtr
         if tp_flags & Py_TPFLAGS_STRING_SUBCLASS:
-            return PyStringObjectPtr
+            return PyBytesObjectPtr
         if tp_flags & Py_TPFLAGS_UNICODE_SUBCLASS:
             return PyUnicodeObjectPtr
         if tp_flags & Py_TPFLAGS_DICT_SUBCLASS:
@@ -958,8 +958,8 @@
         out.write('])')
 
 
-class PyStringObjectPtr(PyObjectPtr):
-    _typename = 'PyStringObject'
+class PyBytesObjectPtr(PyObjectPtr):
+    _typename = 'PyBytesObject'
 
     def __str__(self):
         field_ob_size = self.field('ob_size')


More information about the Python-checkins mailing list