From 30f57c97c7c10421c0dab30fd437f7aa1dd9e9e9 2021-10-18 22:42:39 From: Matthias Bussonnier Date: 2021-10-18 22:42:39 Subject: [PATCH] Merge pull request #13201 from meeseeksmachine/auto-backport-of-pr-13181-on-7.x Backport PR #13181 on branch 7.x (create ipython_dir if not exists) --- diff --git a/IPython/core/tests/test_paths.py b/IPython/core/tests/test_paths.py index ab1c413..2182cb7 100644 --- a/IPython/core/tests/test_paths.py +++ b/IPython/core/tests/test_paths.py @@ -160,6 +160,10 @@ def test_get_ipython_dir_7(): @skip_win32 def test_get_ipython_dir_8(): """test_get_ipython_dir_8, test / home directory""" + if not os.access("/", os.W_OK): + # test only when HOME directory actually writable + return + with patch.object(paths, '_writable_dir', lambda path: bool(path)), \ patch.object(paths, 'get_xdg_dir', return_value=None), \ modified_env({ diff --git a/IPython/paths.py b/IPython/paths.py index bbe3d5c..e7f8aee 100644 --- a/IPython/paths.py +++ b/IPython/paths.py @@ -66,6 +66,8 @@ def get_ipython_dir() -> str: warn("IPython parent '{0}' is not a writable location," " using a temp directory.".format(parent)) ipdir = tempfile.mkdtemp() + else: + os.makedirs(ipdir) assert isinstance(ipdir, str), "all path manipulation should be str(unicode), but are not." return ipdir