From a55b74a629425e3344c8bad7b5994ebfc5b12085 2010-10-10 05:16:27 From: Fernando Perez Date: 2010-10-10 05:16:27 Subject: [PATCH] Work around bug in pprint.pformat. Closes gh-148 --- diff --git a/IPython/core/displayhook.py b/IPython/core/displayhook.py index 55accc5..b98a3bd 100644 --- a/IPython/core/displayhook.py +++ b/IPython/core/displayhook.py @@ -193,7 +193,11 @@ class DisplayHook(Configurable): """ try: if self.shell.pprint: - result_repr = pformat(result) + try: + result_repr = pformat(result) + except: + # Work around possible bugs in pformat + result_repr = repr(result) if '\n' in result_repr: # So that multi-line strings line up with the left column of # the screen, instead of having the output prompt mess up diff --git a/IPython/core/hooks.py b/IPython/core/hooks.py index 2dc377e..1894572 100644 --- a/IPython/core/hooks.py +++ b/IPython/core/hooks.py @@ -163,7 +163,11 @@ def result_display(self,arg): """ if self.pprint: - out = pformat(arg) + try: + out = pformat(arg) + except: + # Work around possible bugs in pformat + out = repr(arg) if '\n' in out: # So that multi-line strings line up with the left column of # the screen, instead of having the output prompt mess up