Permalink
Browse files

More Python 3 compatibility fixes in core.

  • Loading branch information...
1 parent 17afbbe commit ef3358bc6e38958732ac54f1926858bc02f1c138 @takluyver committed Aug 2, 2011
Showing with 4 additions and 3 deletions.
  1. +2 −1 IPython/core/formatters.py
  2. +2 −2 IPython/core/inputsplitter.py
@@ -29,6 +29,7 @@
from IPython.config.configurable import Configurable
from IPython.lib import pretty
from IPython.utils.traitlets import Bool, Dict, Int, Unicode, CUnicode, ObjectName
+from IPython.utils.py3compat import unicode_to_str
#-----------------------------------------------------------------------------
@@ -439,7 +440,7 @@ def __call__(self, obj):
# 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.encode(),
+ self.max_width, unicode_to_str(self.newline),
singleton_pprinters=self.singleton_printers,
type_pprinters=self.type_printers,
deferred_pprinters=self.deferred_printers)
@@ -75,6 +75,7 @@
# IPython modules
from IPython.utils.text import make_quoted_expr
+from IPython.utils.py3compat import cast_unicode
#-----------------------------------------------------------------------------
# Globals
@@ -837,8 +838,7 @@ def push(self, lines):
return super(IPythonInputSplitter, self).push(lines)
# We must ensure all input is pure unicode
- if type(lines)==str:
- lines = lines.decode(self.encoding)
+ lines = cast_unicode(lines, self.encoding)
lines_list = lines.splitlines()

0 comments on commit ef3358b

Please sign in to comment.