10000 Merge pull request #6193 from KanwarGill/mkdtempfix · matplotlib/matplotlib@4e14ae0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e14ae0

Browse files
committed
Merge pull request #6193 from KanwarGill/mkdtempfix
MNT: Make use of mkdtemp when creating temporary config directory. Fix #4597
2 parents 36fafad + 5ff5c90 commit 4e14ae0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/matplotlib/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,16 +553,14 @@ def _create_tmp_config_dir():
553553
# Some restricted platforms (such as Google App Engine) do not provide
554554
# gettempdir.
555555
return None
556-
557556
try:
558557
username = getpass.getuser()
559558
except KeyError:
560559
username = str(os.getuid())
561-
tempdir = os.path.join(tempdir, 'matplotlib-%s' % username)
562560

563-
os.environ['MPLCONFIGDIR'] = tempdir
561+
tempdir = tempfile.mkdtemp(prefix='matplotlib-%s-' % username, dir=tempdir)
564562

565-
mkdirs(tempdir)
563+
os.environ['MPLCONFIGDIR'] = tempdir
566564

567565
return tempdir
568566

0 commit comments

Comments
 (0)
0