8000 Merge pull request #5954 from cancan101/patch-1 · matplotlib/matplotlib@b42984d · GitHub
[go: up one dir, main page]

Skip to content

Commit b42984d

Browse files
committed
Merge pull request #5954 from cancan101/patch-1
Fix issues with getting tempdir when unknown uid
2 parents bbe421a + c041352 commit b42984d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/matplotlib/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,13 @@ def _create_tmp_config_dir():
553553
# Some restricted platforms (such as Google App Engine) do not provide
554554
# gettempdir.
555555
return None
556-
tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser())
556+
557+
try:
558+
username = getpass.getuser()
559+
except KeyError:
560+
username = str(os.getuid())
561+
tempdir = os.path.join(tempdir, 'matplotlib-%s' % username)
562+
557563
os.environ['MPLCONFIGDIR'] = tempdir
558564

559565
mkdirs(tempdir)

0 commit comments

Comments
 (0)
0