Repository: ipython/ipython

Issue:
extreme truncating of return values
while stepping through a function, when printing return values, ipython truncates them quite a bit - you get things like 

```
<Context...ble.txt'>
```

Where in the code is this done?  I haven't been able to find it.  I want to give it more room - at least 80 chars wide would be fine.  



Discussion:
Can you give an example session that demonstrates this? I don't think I've seen it.

```
def test():
    import ipdb;ipdb.set_trace()
    return '123456789012---------------------------------1234567890123'

test()
```

if you run this, then do 'n':

```
ipdb> n
--Return--
'123456789012...1234567890123'
```

It truncates to 28 characters.  My original example was a django error where it truncated a bit more.

But both of these are too much, I think.  I have lots of columns & want to use them.

Ah, debugging, right. No, I don't know what's doing that. I've had a look through IPython.core.debugger and I can't see anything about truncation.


Resolving patch:
diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py
--- a/IPython/core/debugger.py
+++ b/IPython/core/debugger.py
@@ -123,6 +123,22 @@ def __init__(self,colors=None):
 
         if colors is None:
             colors = def_colors
+
+        # The stdlib debugger internally uses a modified repr from the `repr`
+        # module, that limits the length of printed strings to a hardcoded
+        # limit of 30 characters.  That much trimming is too aggressive, let's
+        # at least raise that limit to 80 chars, which should be enough for
+        # most interactive uses.
+        try:
+            from repr import aRepr
+            aRepr.maxstring = 80
+        except:
+            # This is only a user-facing convenience, so any error we encounter
+            # here can be warned about but can be otherwise ignored.  These
+            # printouts will tell us about problems if this API changes 
+            import traceback
+            traceback.print_exc()
+
         self.debugger = Pdb(colors)
 
     def __call__(self):


Test patch:
diff --git a/IPython/core/tests/test_debugger.py b/IPython/core/tests/test_debugger.py
new file mode 100644
--- /dev/null
+++ b/IPython/core/tests/test_debugger.py
@@ -0,0 +1,35 @@
+"""Tests for debugging machinery.
+"""
+#-----------------------------------------------------------------------------
+#  Copyright (c) 2012, The IPython Development Team.
+#
+#  Distributed under the terms of the Modified BSD License.
+#
+#  The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Imports
+#-----------------------------------------------------------------------------
+
+# third-party
+import nose.tools as nt
+
+# Our own
+from IPython.core import debugger
+
+#-----------------------------------------------------------------------------
+# Tests
+#-----------------------------------------------------------------------------
+
+def test_longer_repr():
+    from repr import repr as trepr
+    
+    a = '1234567890'* 7
+    ar = "'1234567890123456789012345678901234567890123456789012345678901234567890'"
+    a_trunc = "'123456789012...8901234567890'"
+    nt.assert_equals(trepr(a), a_trunc)
+    # The creation of our tracer modifies the repr module's repr function
+    # in-place, since that global is used directly by the stdlib's pdb module.
+    t = debugger.Tracer()
+    nt.assert_equals(trepr(a), ar)