diff --git a/IPython/utils/path.py b/IPython/utils/path.py index 69ab3d9..a5e6db2 100644 --- a/IPython/utils/path.py +++ b/IPython/utils/path.py @@ -441,7 +441,7 @@ def ensure_dir_exists(path, mode=0o755): try: path_exists = os.path.exists(path) except UnicodeEncodeError: - path = path.encode("utf8") + path = path.encode(sys.getfilesystemencoding() or "utf8") path_exists = os.path.exists(path) if not os.path.exists(path):