##// END OF EJS Templates
don't add unicode paths to sys.path...
MinRK -
Show More
@@ -211,9 +211,15 b' class BaseIPythonApplication(Application):'
211 return crashhandler.crash_handler_lite(etype, evalue, tb)
211 return crashhandler.crash_handler_lite(etype, evalue, tb)
212
212
213 def _ipython_dir_changed(self, name, old, new):
213 def _ipython_dir_changed(self, name, old, new):
214 if old in sys.path:
214 str_old = py3compat.cast_bytes_py2(os.path.abspath(old),
215 sys.path.remove(old)
215 sys.getfilesystemencoding()
216 sys.path.append(os.path.abspath(new))
216 )
217 if str_old in sys.path:
218 sys.path.remove(str_old)
219 str_path = py3compat.cast_bytes_py2(os.path.abspath(new),
220 sys.getfilesystemencoding()
221 )
222 sys.path.append(str_path)
217 if not os.path.isdir(new):
223 if not os.path.isdir(new):
218 os.makedirs(new, mode=0o777)
224 os.makedirs(new, mode=0o777)
219 readme = os.path.join(new, 'README')
225 readme = os.path.join(new, 'README')
@@ -20,6 +20,8 b' Authors:'
20
20
21 import sys
21 import sys
22
22
23 from IPython.utils.py3compat import cast_bytes_py2
24
23 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
24 # Code
26 # Code
25 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
@@ -28,7 +30,7 b' class appended_to_syspath(object):'
28 """A context for appending a directory to sys.path for a second."""
30 """A context for appending a directory to sys.path for a second."""
29
31
30 def __init__(self, dir):
32 def __init__(self, dir):
31 self.dir = dir
33 self.dir = cast_bytes_py2(dir, sys.getdefaultencoding())
32
34
33 def __enter__(self):
35 def __enter__(self):
34 if self.dir not in sys.path:
36 if self.dir not in sys.path:
@@ -50,7 +52,7 b' class prepended_to_syspath(object):'
50 """A context for prepending a directory to sys.path for a second."""
52 """A context for prepending a directory to sys.path for a second."""
51
53
52 def __init__(self, dir):
54 def __init__(self, dir):
53 self.dir = dir
55 self.dir = cast_bytes_py2(dir, sys.getdefaultencoding())
54
56
55 def __enter__(self):
57 def __enter__(self):
56 if self.dir not in sys.path:
58 if self.dir not in sys.path:
General Comments 0
You need to be logged in to leave comments. Login now