Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

IPython behaves properly when started in a directory with non-ascii c…

…haracters in the name. + Unit test.

Closes gh-200
  • Loading branch information...
commit 1017c448f8b12104ce0f5e809b13b7000fe8e4d6 1 parent fb96e09
@takluyver takluyver authored
View
6 IPython/core/application.py
@@ -350,13 +350,13 @@ def find_config_file_paths(self):
# our shipped copies of builtin profiles even if they don't have them
# in their local ipython directory.
prof_dir = os.path.join(get_ipython_package_dir(), 'config', 'profile')
- self.config_file_paths = (os.getcwd(), self.ipython_dir, prof_dir)
+ self.config_file_paths = (os.getcwdu(), self.ipython_dir, prof_dir)
def pre_load_file_config(self):
"""Do actions before the config file is loaded."""
pass
- def load_file_config(self):
+ def load_file_config(self, suppress_errors=True):
"""Load the config file.
This tries to load the config file from disk. If successful, the
@@ -377,6 +377,8 @@ def load_file_config(self):
self.config_file_name, exc_info=True)
self.file_config = Config()
except:
+ if not suppress_errors: # For testing purposes
+ raise
self.log.warn("Error loading config file: %s" %
self.config_file_name, exc_info=True)
self.file_config = Config()
View
33 IPython/core/tests/test_application.py
@@ -0,0 +1,33 @@
+"""Tests for IPython.core.application"""
+
+import os
+import tempfile
+
+from IPython.core.application import Application
+
+def test_unicode_cwd():
+ """Check that IPython can start with unicode characters in the path."""
+ wd = tempfile.mkdtemp(suffix="")
+
+ old_wd = os.getcwdu()
+ os.chdir(wd)
+ #raise Exception(repr(os.getcwd()))
+ try:
+ app = Application()
+ # The lines below are copied from Application.initialize()
+ app.create_default_config()
+ app.log_default_config()
+ app.set_default_config_log_level()
+
+ # Find resources needed for filesystem access, using information from
+ # the above two
+ app.find_ipython_dir()
+ app.find_resources()
+ app.find_config_file_name()
+ app.find_config_file_paths()
+
+ # File-based config
+ app.pre_load_file_config()
+ app.load_file_config(suppress_errors=False)
+ finally:
+ os.chdir(old_wd)
View
4 IPython/core/tests/test_magic.py
@@ -293,9 +293,9 @@ def test_parse_options():
def test_dirops():
"""Test various directory handling operations."""
- curpath = lambda :os.path.splitdrive(os.getcwd())[1].replace('\\','/')
+ curpath = lambda :os.path.splitdrive(os.getcwdu())[1].replace('\\','/')
- startdir = os.getcwd()
+ startdir = os.getcwdu()
ipdir = _ip.ipython_dir
try:
_ip.magic('cd "%s"' % ipdir)
Please sign in to comment.
Something went wrong with that request. Please try again.