Skip to content

Commit

Permalink
IPython/utils/path.py: If os.path.exists cannot handle a unicode
Browse files Browse the repository at this point in the history
…path, as has been found in some cases, go ahead and convert to a `byte` path, which is hopefully supported.
  • Loading branch information
jakirkham committed Oct 9, 2015
1 parent f14d4ad commit 3b221ff
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions IPython/utils/path.py
Expand Up @@ -437,6 +437,13 @@ def ensure_dir_exists(path, mode=0o755):
The default permissions are 755, which differ from os.makedirs default of 777.
"""
path_exists = False
try:
path_exists = os.path.exists(path)
except UnicodeEncodeError:
path = path.encode("utf8")
path_exists = os.path.exists(path)

if not os.path.exists(path):
try:
os.makedirs(path, mode=mode)
Expand Down

0 comments on commit 3b221ff

Please sign in to comment.