10000 Fix issues with getting tempdir when unknown uid · matplotlib/matplotlib@c041352 · GitHub
[go: up one dir, main page]

Skip to content

Commit c041352

Browse files
committed
Fix issues with getting tempdir when unknown uid
Closes #5940
1 parent bbe421a commit c041352

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