##// END OF EJS Templates
rm cast_bytes_py2
Srinivas Reddy Thatiparthy -
Show More
@@ -260,14 +260,10 b' class BaseIPythonApplication(Application):'
260 old = change['old']
260 old = change['old']
261 new = change['new']
261 new = change['new']
262 if old is not Undefined:
262 if old is not Undefined:
263 str_old = py3compat.cast_bytes_py2(os.path.abspath(old),
263 str_old = os.path.abspath(old)
264 sys.getfilesystemencoding()
265 )
266 if str_old in sys.path:
264 if str_old in sys.path:
267 sys.path.remove(str_old)
265 sys.path.remove(str_old)
268 str_path = py3compat.cast_bytes_py2(os.path.abspath(new),
266 str_path = os.path.abspath(new)
269 sys.getfilesystemencoding()
270 )
271 sys.path.append(str_path)
267 sys.path.append(str_path)
272 ensure_dir_exists(new)
268 ensure_dir_exists(new)
273 readme = os.path.join(new, 'README')
269 readme = os.path.join(new, 'README')
@@ -18,7 +18,7 b' import struct'
18 import sys
18 import sys
19 import warnings
19 import warnings
20
20
21 from IPython.utils.py3compat import cast_bytes_py2, cast_unicode
21 from IPython.utils.py3compat import cast_unicode
22 from IPython.testing.skipdoctest import skip_doctest
22 from IPython.testing.skipdoctest import skip_doctest
23
23
24 __all__ = ['display', 'display_pretty', 'display_html', 'display_markdown',
24 __all__ = ['display', 'display_pretty', 'display_html', 'display_markdown',
@@ -596,7 +596,6 b' class SVG(DisplayObject):'
596 return
596 return
597 # parse into dom object
597 # parse into dom object
598 from xml.dom import minidom
598 from xml.dom import minidom
599 svg = cast_bytes_py2(svg)
600 x = minidom.parseString(svg)
599 x = minidom.parseString(svg)
601 # get svg tag (should be 1)
600 # get svg tag (should be 1)
602 found_svg = x.getElementsByTagName('svg')
601 found_svg = x.getElementsByTagName('svg')
@@ -887,7 +887,7 b' class InteractiveShell(SingletonConfigurable):'
887 main_mod = self._main_mod_cache[filename]
887 main_mod = self._main_mod_cache[filename]
888 except KeyError:
888 except KeyError:
889 main_mod = self._main_mod_cache[filename] = types.ModuleType(
889 main_mod = self._main_mod_cache[filename] = types.ModuleType(
890 py3compat.cast_bytes_py2(modname),
890 modname,
891 doc="Module created for script run in IPython")
891 doc="Module created for script run in IPython")
892 else:
892 else:
893 main_mod.__dict__.clear()
893 main_mod.__dict__.clear()
@@ -1875,7 +1875,7 b' class InteractiveShell(SingletonConfigurable):'
1875 In [1]: _ip.set_next_input("Hello Word")
1875 In [1]: _ip.set_next_input("Hello Word")
1876 In [2]: Hello Word_ # cursor is here
1876 In [2]: Hello Word_ # cursor is here
1877 """
1877 """
1878 self.rl_next_input = py3compat.cast_bytes_py2(s)
1878 self.rl_next_input = s
1879
1879
1880 def _indent_current_str(self):
1880 def _indent_current_str(self):
1881 """return the current level of indentation as a string"""
1881 """return the current level of indentation as a string"""
@@ -428,7 +428,7 b' class OSMagics(Magics):'
428 err = "refusing to set env var with whitespace: '{0}'"
428 err = "refusing to set env var with whitespace: '{0}'"
429 err = err.format(val)
429 err = err.format(val)
430 raise UsageError(err)
430 raise UsageError(err)
431 os.environ[py3compat.cast_bytes_py2(var)] = py3compat.cast_bytes_py2(val)
431 os.environ[var] = val
432 print('env: {0}={1}'.format(var,val))
432 print('env: {0}={1}'.format(var,val))
433
433
434 @line_magic
434 @line_magic
@@ -231,8 +231,7 b' def pager_page(strng, start=0, screen_lines=0, pager_cmd=None):'
231 pager = os.popen(pager_cmd, 'w')
231 pager = os.popen(pager_cmd, 'w')
232 try:
232 try:
233 pager_encoding = pager.encoding or sys.stdout.encoding
233 pager_encoding = pager.encoding or sys.stdout.encoding
234 pager.write(py3compat.cast_bytes_py2(
234 pager.write(strng)
235 strng, encoding=pager_encoding))
236 finally:
235 finally:
237 retval = pager.close()
236 retval = pager.close()
238 except IOError as msg: # broken pipe when user quits
237 except IOError as msg: # broken pipe when user quits
@@ -14,23 +14,14 b' Authors:'
14 # the file COPYING, distributed as part of this software.
14 # the file COPYING, distributed as part of this software.
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16
16
17 #-----------------------------------------------------------------------------
18 # Imports
19 #-----------------------------------------------------------------------------
20
21 import sys
17 import sys
22
18
23 from IPython.utils.py3compat import cast_bytes_py2
24
25 #-----------------------------------------------------------------------------
26 # Code
27 #-----------------------------------------------------------------------------
28
19
29 class appended_to_syspath(object):
20 class appended_to_syspath(object):
30 """A context for appending a directory to sys.path for a second."""
21 """A context for appending a directory to sys.path for a second."""
31
22
32 def __init__(self, dir):
23 def __init__(self, dir):
33 self.dir = cast_bytes_py2(dir, sys.getdefaultencoding())
24 self.dir = dir
34
25
35 def __enter__(self):
26 def __enter__(self):
36 if self.dir not in sys.path:
27 if self.dir not in sys.path:
@@ -52,7 +43,7 b' class prepended_to_syspath(object):'
52 """A context for prepending a directory to sys.path for a second."""
43 """A context for prepending a directory to sys.path for a second."""
53
44
54 def __init__(self, dir):
45 def __init__(self, dir):
55 self.dir = cast_bytes_py2(dir, sys.getdefaultencoding())
46 self.dir = dir
56
47
57 def __enter__(self):
48 def __enter__(self):
58 if self.dir not in sys.path:
49 if self.dir not in sys.path:
General Comments 0
You need to be logged in to leave comments. Login now