##// END OF EJS Templates
Fix for non-ascii characters in IPYTHONDIR, + unit test.
Thomas Kluyver -
Show More
@@ -285,7 +285,8 b' class PyFileConfigLoader(FileConfigLoader):'
285 return self.config
285 return self.config
286
286
287 namespace = dict(load_subconfig=load_subconfig, get_config=get_config)
287 namespace = dict(load_subconfig=load_subconfig, get_config=get_config)
288 execfile(self.full_filename, namespace)
288 conf_filename = self.full_filename.encode(sys.getfilesystemencoding())
289 execfile(conf_filename, namespace)
289
290
290 def _convert_to_config(self):
291 def _convert_to_config(self):
291 if self.data is None:
292 if self.data is None:
@@ -6,7 +6,7 b' import tempfile'
6 from IPython.core.application import Application
6 from IPython.core.application import Application
7
7
8 def test_unicode_cwd():
8 def test_unicode_cwd():
9 """Check that IPython can start with unicode characters in the path."""
9 """Check that IPython starts with non-ascii characters in the path."""
10 wd = tempfile.mkdtemp(suffix="€")
10 wd = tempfile.mkdtemp(suffix="€")
11
11
12 old_wd = os.getcwdu()
12 old_wd = os.getcwdu()
@@ -31,3 +31,37 b' def test_unicode_cwd():'
31 app.load_file_config(suppress_errors=False)
31 app.load_file_config(suppress_errors=False)
32 finally:
32 finally:
33 os.chdir(old_wd)
33 os.chdir(old_wd)
34
35 def test_unicode_ipdir():
36 """Check that IPython starts with non-ascii characters in the IP dir."""
37 ipdir = tempfile.mkdtemp(suffix="€")
38
39 # Create the config file, so it tries to load it.
40 with open(os.path.join(ipdir, 'ipython_config.py'), "w") as f:
41 pass
42
43 old_ipdir1 = os.environ.pop("IPYTHONDIR", None)
44 old_ipdir2 = os.environ.pop("IPYTHON_DIR", None)
45 os.environ["IPYTHONDIR"] = ipdir
46 try:
47 app = Application()
48 # The lines below are copied from Application.initialize()
49 app.create_default_config()
50 app.log_default_config()
51 app.set_default_config_log_level()
52
53 # Find resources needed for filesystem access, using information from
54 # the above two
55 app.find_ipython_dir()
56 app.find_resources()
57 app.find_config_file_name()
58 app.find_config_file_paths()
59
60 # File-based config
61 app.pre_load_file_config()
62 app.load_file_config(suppress_errors=False)
63 finally:
64 if old_ipdir1:
65 os.environ["IPYTHONDIR"] = old_ipdir1
66 if old_ipdir2:
67 os.environ["IPYTHONDIR"] = old_ipdir2
General Comments 0
You need to be logged in to leave comments. Login now