diff --git a/IPython/core/application.py b/IPython/core/application.py index d6ad998..b8f0472 100644 --- a/IPython/core/application.py +++ b/IPython/core/application.py @@ -260,14 +260,10 @@ class BaseIPythonApplication(Application): old = change['old'] new = change['new'] if old is not Undefined: - str_old = py3compat.cast_bytes_py2(os.path.abspath(old), - sys.getfilesystemencoding() - ) + str_old = os.path.abspath(old) if str_old in sys.path: sys.path.remove(str_old) - str_path = py3compat.cast_bytes_py2(os.path.abspath(new), - sys.getfilesystemencoding() - ) + str_path = os.path.abspath(new) sys.path.append(str_path) ensure_dir_exists(new) readme = os.path.join(new, 'README') diff --git a/IPython/core/display.py b/IPython/core/display.py index 8fd52b5..e1875e1 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -18,7 +18,7 @@ import struct import sys import warnings -from IPython.utils.py3compat import cast_bytes_py2, cast_unicode +from IPython.utils.py3compat import cast_unicode from IPython.testing.skipdoctest import skip_doctest __all__ = ['display', 'display_pretty', 'display_html', 'display_markdown', @@ -596,7 +596,6 @@ class SVG(DisplayObject): return # parse into dom object from xml.dom import minidom - svg = cast_bytes_py2(svg) x = minidom.parseString(svg) # get svg tag (should be 1) found_svg = x.getElementsByTagName('svg') diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index e93ff0b..a94e9a5 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -887,7 +887,7 @@ class InteractiveShell(SingletonConfigurable): main_mod = self._main_mod_cache[filename] except KeyError: main_mod = self._main_mod_cache[filename] = types.ModuleType( - py3compat.cast_bytes_py2(modname), + modname, doc="Module created for script run in IPython") else: main_mod.__dict__.clear() @@ -1875,7 +1875,7 @@ class InteractiveShell(SingletonConfigurable): In [1]: _ip.set_next_input("Hello Word") In [2]: Hello Word_ # cursor is here """ - self.rl_next_input = py3compat.cast_bytes_py2(s) + self.rl_next_input = s def _indent_current_str(self): """return the current level of indentation as a string""" diff --git a/IPython/core/magics/osm.py b/IPython/core/magics/osm.py index 72f264e..9436ee4 100644 --- a/IPython/core/magics/osm.py +++ b/IPython/core/magics/osm.py @@ -428,7 +428,7 @@ class OSMagics(Magics): err = "refusing to set env var with whitespace: '{0}'" err = err.format(val) raise UsageError(err) - os.environ[py3compat.cast_bytes_py2(var)] = py3compat.cast_bytes_py2(val) + os.environ[var] = val print('env: {0}={1}'.format(var,val)) @line_magic diff --git a/IPython/core/page.py b/IPython/core/page.py index 0a9e4f0..4499609 100644 --- a/IPython/core/page.py +++ b/IPython/core/page.py @@ -231,8 +231,7 @@ def pager_page(strng, start=0, screen_lines=0, pager_cmd=None): pager = os.popen(pager_cmd, 'w') try: pager_encoding = pager.encoding or sys.stdout.encoding - pager.write(py3compat.cast_bytes_py2( - strng, encoding=pager_encoding)) + pager.write(strng) finally: retval = pager.close() except IOError as msg: # broken pipe when user quits diff --git a/IPython/utils/syspathcontext.py b/IPython/utils/syspathcontext.py index 8961203..bd1c515 100644 --- a/IPython/utils/syspathcontext.py +++ b/IPython/utils/syspathcontext.py @@ -14,23 +14,14 @@ Authors: # the file COPYING, distributed as part of this software. #----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- - import sys -from IPython.utils.py3compat import cast_bytes_py2 - -#----------------------------------------------------------------------------- -# Code -#----------------------------------------------------------------------------- class appended_to_syspath(object): """A context for appending a directory to sys.path for a second.""" def __init__(self, dir): - self.dir = cast_bytes_py2(dir, sys.getdefaultencoding()) + self.dir = dir def __enter__(self): if self.dir not in sys.path: @@ -52,7 +43,7 @@ class prepended_to_syspath(object): """A context for prepending a directory to sys.path for a second.""" def __init__(self, dir): - self.dir = cast_bytes_py2(dir, sys.getdefaultencoding()) + self.dir = dir def __enter__(self): if self.dir not in sys.path: