Skip to content

Commit

Permalink
Merge branch 'i597'
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Jul 22, 2011
2 parents ff5e7cd + b924107 commit 6b2de8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion IPython/core/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,11 @@ def __call__(self, obj):
else:
# This uses use StringIO, as cStringIO doesn't handle unicode.
stream = StringIO()
# self.newline.encode() is a quick fix for issue gh-597. We need to
# ensure that stream does not get a mix of unicode and bytestrings,
# or it will cause trouble.
printer = pretty.RepresentationPrinter(stream, self.verbose,
self.max_width, self.newline,
self.max_width, self.newline.encode(),
singleton_pprinters=self.singleton_printers,
type_pprinters=self.type_printers,
deferred_pprinters=self.deferred_printers)
Expand Down
12 changes: 10 additions & 2 deletions IPython/core/tests/test_interactiveshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,13 @@ def test_trailing_newline(self):
ip = get_ipython()
ip.run_cell('!(true)\n', False)
ip.run_cell('!(true)\n\n\n', False)



def test_gh_597(self):
"""Pretty-printing lists of objects with non-ascii reprs may cause
problems."""
class Spam(object):
def __repr__(self):
return "\xe9"*50
import IPython.core.formatters
f = IPython.core.formatters.PlainTextFormatter()
f([Spam(),Spam()])

0 comments on commit 6b2de8f

Please sign in to comment.