8000 Resolve configdir to handle potential issues with inaccessible symlinks · matplotlib/matplotlib@957271f · GitHub
[go: up one dir, main page]

Skip to content

Commit 957271f

Browse files
hintrongreglucas
andcommitted
Resolve configdir to handle potential issues with inaccessible symlinks
There are some use cases where a user might have a symlinked home directory (e.g. a corporate home directory may be symlinked to a disk with limited space, and is only accessible to other users via a real path to the underlying disk). Resolving configdir before any mkdir or access checks should avoid this problem. Co-authored-by: Greg Lucas <greg.m.lucas@gmail.com>
1 parent 42b88d0 commit 957271f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,15 @@ def _get_xdg_cache_dir():
519519
def _get_config_or_cache_dir(xdg_base_getter):
520520
configdir = os.environ.get('MPLCONFIGDIR')
521521
if configdir:
522-
configdir = Path(configdir).resolve()
522+
configdir = Path(configdir)
523523
elif sys.platform.startswith(('linux', 'freebsd')):
524524
# Only call _xdg_base_getter here so that MPLCONFIGDIR is tried first,
525525
# as _xdg_base_getter can throw.
526526
configdir = Path(xdg_base_getter(), "matplotlib")
527527
else:
528528
configdir = Path.home() / ".matplotlib"
529+
# Resolve the path to handle potential issues with inaccessible symlinks.
530+
configdir = configdir.resolve()
529531
try:
530532
configdir.mkdir(parents=True, exist_ok=True)
531533
except OSError:

0 commit comments

Comments
 (0)
0