##// END OF EJS Templates
More Python 3 compatibility fixes in core.
Thomas Kluyver -
Show More
@@ -29,6 +29,7 b' from StringIO import StringIO'
29 from IPython.config.configurable import Configurable
29 from IPython.config.configurable import Configurable
30 from IPython.lib import pretty
30 from IPython.lib import pretty
31 from IPython.utils.traitlets import Bool, Dict, Int, Unicode, CUnicode, ObjectName
31 from IPython.utils.traitlets import Bool, Dict, Int, Unicode, CUnicode, ObjectName
32 from IPython.utils.py3compat import unicode_to_str
32
33
33
34
34 #-----------------------------------------------------------------------------
35 #-----------------------------------------------------------------------------
@@ -439,7 +440,7 b' class PlainTextFormatter(BaseFormatter):'
439 # ensure that stream does not get a mix of unicode and bytestrings,
440 # ensure that stream does not get a mix of unicode and bytestrings,
440 # or it will cause trouble.
441 # or it will cause trouble.
441 printer = pretty.RepresentationPrinter(stream, self.verbose,
442 printer = pretty.RepresentationPrinter(stream, self.verbose,
442 self.max_width, self.newline.encode(),
443 self.max_width, unicode_to_str(self.newline),
443 singleton_pprinters=self.singleton_printers,
444 singleton_pprinters=self.singleton_printers,
444 type_pprinters=self.type_printers,
445 type_pprinters=self.type_printers,
445 deferred_pprinters=self.deferred_printers)
446 deferred_pprinters=self.deferred_printers)
@@ -75,6 +75,7 b' from StringIO import StringIO'
75
75
76 # IPython modules
76 # IPython modules
77 from IPython.utils.text import make_quoted_expr
77 from IPython.utils.text import make_quoted_expr
78 from IPython.utils.py3compat import cast_unicode
78
79
79 #-----------------------------------------------------------------------------
80 #-----------------------------------------------------------------------------
80 # Globals
81 # Globals
@@ -837,8 +838,7 b' class IPythonInputSplitter(InputSplitter):'
837 return super(IPythonInputSplitter, self).push(lines)
838 return super(IPythonInputSplitter, self).push(lines)
838
839
839 # We must ensure all input is pure unicode
840 # We must ensure all input is pure unicode
840 if type(lines)==str:
841 lines = cast_unicode(lines, self.encoding)
841 lines = lines.decode(self.encoding)
842
842
843 lines_list = lines.splitlines()
843 lines_list = lines.splitlines()
844
844
General Comments 0
You need to be logged in to leave comments. Login now