From a82de5ccc4c5f3ebacf4c97cdae6da3eb1bfb57d Mon Sep 17 00:00:00 2001 From: Eugen Beck Date: Mon, 6 Jul 2015 12:14:44 +0200 Subject: [PATCH 1/2] _create_tmp_config_dir() "mkdirs" the returned dir Fixes #4120 --- lib/matplotlib/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index e6971702ab75..e072c12cd17a 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -537,6 +537,7 @@ def _create_tmp_config_dir(): """ import getpass import tempfile + from matplotlib.cbook import mkdirs try: tempdir = tempfile.gettempdir() @@ -547,6 +548,11 @@ def _create_tmp_config_dir(): tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser()) os.environ['MPLCONFIGDIR'] = tempdir + try: + mkdirs(tempdir) + except OSError: + pass + return tempdir From 0f8305c8d5fc0c81caf9aeb620f98f78f77dffef Mon Sep 17 00:00:00 2001 From: Eugen Beck Date: Mon, 6 Jul 2015 22:01:41 +0200 Subject: [PATCH 2/2] Fixed exception handling in _create_tmp_config_dir --- lib/matplotlib/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index e072c12cd17a..10ba3fac0292 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -548,10 +548,7 @@ def _create_tmp_config_dir(): tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser()) os.environ['MPLCONFIGDIR'] = tempdir - try: - mkdirs(tempdir) - except OSError: - pass + mkdirs(tempdir) return tempdir