a0eea87
diff -up Python-2.7.3/Tools/gdb/libpython.py.fix-fake-repr-in-gdb-hooks Python-2.7.3/Tools/gdb/libpython.py
a0eea87
--- Python-2.7.3/Tools/gdb/libpython.py.fix-fake-repr-in-gdb-hooks	2013-02-19 17:21:33.541181366 -0500
a0eea87
+++ Python-2.7.3/Tools/gdb/libpython.py	2013-02-19 17:21:42.090180782 -0500
a0eea87
@@ -105,6 +105,24 @@ class TruncatedStringIO(object):
a0eea87
     def getvalue(self):
a0eea87
         return self._val
a0eea87
 
a0eea87
+class FakeProxy(object):
a0eea87
+    """
a0eea87
+    Class representing a non-descript PyObject* value in the inferior
a0eea87
+    process for when we don't have a custom scraper, intended to have
a0eea87
+    a sane repr().
a0eea87
+    """
a0eea87
+    def __init__(self, tp_name, address):
a0eea87
+        self.tp_name = tp_name
a0eea87
+        self.address = address
a0eea87
+
a0eea87
+    def __repr__(self):
a0eea87
+        # For the NULL pointer, we have no way of knowing a type, so
a0eea87
+        # special-case it as per
a0eea87
+        # http://bugs.python.org/issue8032#msg100882
a0eea87
+        if self.address == 0:
a0eea87
+            return '0x0'
a0eea87
+        return '<%s at remote 0x%x>' % (self.tp_name, self.address)
a0eea87
+
a0eea87
 class PyObjectPtr(object):
a0eea87
     """
a0eea87
     Class wrapping a gdb.Value that's a either a (PyObject*) within the
a0eea87
@@ -232,28 +250,8 @@ class PyObjectPtr(object):
a0eea87
         visiting object graphs with loops).  Analogous to Py_ReprEnter and
a0eea87
         Py_ReprLeave
a0eea87
         '''
a0eea87
-
a0eea87
-        class FakeRepr(object):
a0eea87
-            """
a0eea87
-            Class representing a non-descript PyObject* value in the inferior
a0eea87
-            process for when we don't have a custom scraper, intended to have
a0eea87
-            a sane repr().
a0eea87
-            """
a0eea87
-
a0eea87
-            def __init__(self, tp_name, address):
a0eea87
-                self.tp_name = tp_name
a0eea87
-                self.address = address
a0eea87
-
a0eea87
-            def __repr__(self):
a0eea87
-                # For the NULL pointer, we have no way of knowing a type, so
a0eea87
-                # special-case it as per
a0eea87
-                # http://bugs.python.org/issue8032#msg100882
a0eea87
-                if self.address == 0:
a0eea87
-                    return '0x0'
a0eea87
-                return '<%s at remote 0x%x>' % (self.tp_name, self.address)
a0eea87
-
a0eea87
-        return FakeRepr(self.safe_tp_name(),
a0eea87
-                        long(self._gdbval))
a0eea87
+        return FakeProxy(self.safe_tp_name(),
a0eea87
+                         long(self._gdbval))
a0eea87
 
a0eea87
     def write_repr(self, out, visited):
a0eea87
         '''
a0eea87
@@ -384,7 +382,7 @@ def _write_instance_repr(out, visited, n
a0eea87
             if not first:
a0eea87
                 out.write(', ')
a0eea87
             first = False
a0eea87
-            out.write(pyop_arg.proxyval(visited))
a0eea87
+            out.write(str(pyop_arg.proxyval(visited)))
a0eea87
             out.write('=')
a0eea87
             pyop_val.write_repr(out, visited)
a0eea87
         out.write(')')
a0eea87
@@ -785,6 +783,8 @@ class PyNoneStructPtr(PyObjectPtr):
a0eea87
     def proxyval(self, visited):
a0eea87
         return None
a0eea87
 
a0eea87
+class CantReadFilename(ValueError):
a0eea87
+    pass
a0eea87
 
a0eea87
 class PyFrameObjectPtr(PyObjectPtr):
a0eea87
     _typename = 'PyFrameObject'
a0eea87
@@ -861,7 +861,10 @@ class PyFrameObjectPtr(PyObjectPtr):
a0eea87
         '''Get the path of the current Python source file, as a string'''
a0eea87
         if self.is_optimized_out():
a0eea87
             return '(frame information optimized out)'
a0eea87
-        return self.co_filename.proxyval(set())
a0eea87
+        value = self.co_filename.proxyval(set())
a0eea87
+        if isinstance(value, FakeProxy):
a0eea87
+            raise CantReadFilename('unable to extract filename)')
a0eea87
+        return value
a0eea87
 
a0eea87
     def current_line_num(self):
a0eea87
         '''Get current line number as an integer (1-based)
a0eea87
@@ -907,7 +910,7 @@ class PyFrameObjectPtr(PyObjectPtr):
a0eea87
                 out.write(', ')
a0eea87
             first = False
a0eea87
 
a0eea87
-            out.write(pyop_name.proxyval(visited))
a0eea87
+            out.write(str(pyop_name.proxyval(visited)))
a0eea87
             out.write('=')
a0eea87
             pyop_value.write_repr(out, visited)
a0eea87
 
a0eea87
@@ -1252,8 +1255,11 @@ class Frame(object):
a0eea87
             if pyop:
a0eea87
                 sys.stdout.write('#%i %s\n' % (self.get_index(), pyop.get_truncated_repr(MAX_OUTPUT_LEN)))
a0eea87
                 if not pyop.is_optimized_out():
a0eea87
-                    line = pyop.current_line()
a0eea87
-                    sys.stdout.write('    %s\n' % line.strip())
a0eea87
+                    try:
a0eea87
+                        line = pyop.current_line()
a0eea87
+                        sys.stdout.write('    %s\n' % line.strip())
a0eea87
+                    except CantReadFilename:
a0eea87
+                        sys.stdout.write('    %s\n' % '(unable to read filename)')
a0eea87
             else:
a0eea87
                 sys.stdout.write('#%i (unable to read python frame information)\n' % self.get_index())
a0eea87
         else:
a0eea87
@@ -1303,7 +1309,11 @@ class PyList(gdb.Command):
a0eea87
             print 'Unable to read information on python frame'
a0eea87
             return
a0eea87
 
a0eea87
-        filename = pyop.filename()
a0eea87
+        try:
a0eea87
+            filename = pyop.filename()
a0eea87
+        except CantReadFilename:
a0eea87
+            print "Unable to extract filename from python frame"
a0eea87
+            return
a0eea87
         lineno = pyop.current_line_num()
a0eea87
 
a0eea87
         if start is None: