##// END OF EJS Templates
Merge branch 'i597'
Thomas Kluyver -
r4377:6b2de8fd merge
parent child Browse files
Show More
@@ -432,8 +432,11 b' class PlainTextFormatter(BaseFormatter):'
432 else:
432 else:
433 # This uses use StringIO, as cStringIO doesn't handle unicode.
433 # This uses use StringIO, as cStringIO doesn't handle unicode.
434 stream = StringIO()
434 stream = StringIO()
435 # self.newline.encode() is a quick fix for issue gh-597. We need to
436 # ensure that stream does not get a mix of unicode and bytestrings,
437 # or it will cause trouble.
435 printer = pretty.RepresentationPrinter(stream, self.verbose,
438 printer = pretty.RepresentationPrinter(stream, self.verbose,
436 self.max_width, self.newline,
439 self.max_width, self.newline.encode(),
437 singleton_pprinters=self.singleton_printers,
440 singleton_pprinters=self.singleton_printers,
438 type_pprinters=self.type_printers,
441 type_pprinters=self.type_printers,
439 deferred_pprinters=self.deferred_printers)
442 deferred_pprinters=self.deferred_printers)
@@ -113,4 +113,12 b' class InteractiveShellTestCase(unittest.TestCase):'
113 ip.run_cell('!(true)\n', False)
113 ip.run_cell('!(true)\n', False)
114 ip.run_cell('!(true)\n\n\n', False)
114 ip.run_cell('!(true)\n\n\n', False)
115
115
116
116 def test_gh_597(self):
117 """Pretty-printing lists of objects with non-ascii reprs may cause
118 problems."""
119 class Spam(object):
120 def __repr__(self):
121 return "\xe9"*50
122 import IPython.core.formatters
123 f = IPython.core.formatters.PlainTextFormatter()
124 f([Spam(),Spam()])
General Comments 0
You need to be logged in to leave comments. Login now