From 0ee2e5def26c89b64ba5200d9256304d9c5c2331 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Fri, 7 Sep 2012 12:26:34 -0400 Subject: [PATCH] Put user's name in the temp directory that gets created when the home directory is not writable. Fixes race conditions on a multi-user machine discovered by Matt Anderson. --- lib/matplotlib/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index caa39b817c60..a31e6f0e4cf2 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -471,9 +471,11 @@ def _create_tmp_config_dir(): If the config directory can not be created, create a temporary directory. """ + import getpass import tempfile - tempdir = os.path.join(tempfile.gettempdir(), 'matplotlib') + tempdir = os.path.join( + tempfile.gettempdir(), 'matplotlib-%s' % getpass.getuser()) os.environ['MPLCONFIGDIR'] = tempdir return tempdir