##// END OF EJS Templates
avoid interpreting IOError in config file as file-not-found...
MinRK -
Show More
@@ -27,7 +27,7 b' from copy import deepcopy'
27
27
28 from IPython.config.configurable import SingletonConfigurable
28 from IPython.config.configurable import SingletonConfigurable
29 from IPython.config.loader import (
29 from IPython.config.loader import (
30 KVArgParseConfigLoader, PyFileConfigLoader, Config, ArgumentError
30 KVArgParseConfigLoader, PyFileConfigLoader, Config, ArgumentError, ConfigFileNotFound,
31 )
31 )
32
32
33 from IPython.utils.traitlets import (
33 from IPython.utils.traitlets import (
@@ -370,8 +370,8 b' class Application(SingletonConfigurable):'
370 loader = PyFileConfigLoader(filename, path=path)
370 loader = PyFileConfigLoader(filename, path=path)
371 try:
371 try:
372 config = loader.load_config()
372 config = loader.load_config()
373 except IOError:
373 except ConfigFileNotFound:
374 # problem with the file (probably doesn't exist), raise
374 # problem finding the file, raise
375 raise
375 raise
376 except Exception:
376 except Exception:
377 # try to get the full filename, but it will be empty in the
377 # try to get the full filename, but it will be empty in the
@@ -34,10 +34,12 b' from IPython.utils import py3compat, text, warn'
34 class ConfigError(Exception):
34 class ConfigError(Exception):
35 pass
35 pass
36
36
37
38 class ConfigLoaderError(ConfigError):
37 class ConfigLoaderError(ConfigError):
39 pass
38 pass
40
39
40 class ConfigFileNotFound(ConfigError):
41 pass
42
41 class ArgumentError(ConfigLoaderError):
43 class ArgumentError(ConfigLoaderError):
42 pass
44 pass
43
45
@@ -258,7 +260,10 b' class PyFileConfigLoader(FileConfigLoader):'
258 def load_config(self):
260 def load_config(self):
259 """Load the config from a file and return it as a Struct."""
261 """Load the config from a file and return it as a Struct."""
260 self.clear()
262 self.clear()
261 self._find_file()
263 try:
264 self._find_file()
265 except IOError as e:
266 raise ConfigFileNotFound(str(e))
262 self._read_file_as_dict()
267 self._read_file_as_dict()
263 self._convert_to_config()
268 self._convert_to_config()
264 return self.config
269 return self.config
@@ -297,7 +302,7 b' class PyFileConfigLoader(FileConfigLoader):'
297 loader = PyFileConfigLoader(fname, path)
302 loader = PyFileConfigLoader(fname, path)
298 try:
303 try:
299 sub_config = loader.load_config()
304 sub_config = loader.load_config()
300 except IOError:
305 except ConfigFileNotFound:
301 # Pass silently if the sub config is not there. This happens
306 # Pass silently if the sub config is not there. This happens
302 # when a user s using a profile, but not the default config.
307 # when a user s using a profile, but not the default config.
303 pass
308 pass
General Comments 0
You need to be logged in to leave comments. Login now