##// END OF EJS Templates
Merge pull request #12034 from Carreau/os-environ-is-str...
Matthias Bussonnier -
r25357:ffde0f91 merge
parent child Browse files
Show More
@@ -15,13 +15,11 b' import glob'
15 from warnings import warn
15 from warnings import warn
16
16
17 from IPython.utils.process import system
17 from IPython.utils.process import system
18 from IPython.utils import py3compat
19 from IPython.utils.decorators import undoc
18 from IPython.utils.decorators import undoc
20
19
21 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
22 # Code
21 # Code
23 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
24
25 fs_encoding = sys.getfilesystemencoding()
23 fs_encoding = sys.getfilesystemencoding()
26
24
27 def _writable_dir(path):
25 def _writable_dir(path):
@@ -226,7 +224,8 b' def get_xdg_dir():'
226 # use ~/.config if empty OR not set
224 # use ~/.config if empty OR not set
227 xdg = env.get("XDG_CONFIG_HOME", None) or os.path.join(get_home_dir(), '.config')
225 xdg = env.get("XDG_CONFIG_HOME", None) or os.path.join(get_home_dir(), '.config')
228 if xdg and _writable_dir(xdg):
226 if xdg and _writable_dir(xdg):
229 return py3compat.cast_unicode(xdg, fs_encoding)
227 assert isinstance(xdg, str)
228 return xdg
230
229
231 return None
230 return None
232
231
@@ -244,7 +243,8 b' def get_xdg_cache_dir():'
244 # use ~/.cache if empty OR not set
243 # use ~/.cache if empty OR not set
245 xdg = env.get("XDG_CACHE_HOME", None) or os.path.join(get_home_dir(), '.cache')
244 xdg = env.get("XDG_CACHE_HOME", None) or os.path.join(get_home_dir(), '.cache')
246 if xdg and _writable_dir(xdg):
245 if xdg and _writable_dir(xdg):
247 return py3compat.cast_unicode(xdg, fs_encoding)
246 assert isinstance(xdg, str)
247 return xdg
248
248
249 return None
249 return None
250
250
General Comments 0
You need to be logged in to leave comments. Login now