Skip to content

Commit

Permalink
More Python 3 compatibility fixes in core.
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Sep 7, 2011
1 parent 17afbbe commit ef3358b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion IPython/core/formatters.py
Expand Up @@ -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


#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions IPython/core/inputsplitter.py
Expand Up @@ -75,6 +75,7 @@

# IPython modules
from IPython.utils.text import make_quoted_expr
from IPython.utils.py3compat import cast_unicode

#-----------------------------------------------------------------------------
# Globals
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit ef3358b

Please sign in to comment.