Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b67098b

Browse files
authored
Merge pull request #9570 from anntzer/mplrc
Allow setting MATPLOTLIBRC by process substitution.
2 parents 7ee6499 + 6447ff6 commit b67098b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/matplotlib/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
import os
118118
import re
119119
import shutil
120+
import stat
120121
import sys
121122
import tempfile
122123
import warnings
@@ -792,7 +793,8 @@ def matplotlib_fname():
792793
793794
- `$PWD/matplotlibrc`
794795
795-
- `$MATPLOTLIBRC` if it is a file
796+
- `$MATPLOTLIBRC` if it is a file (or a named pipe, which can be created
797+
e.g. by process substitution)
796798
797799
- `$MATPLOTLIBRC/matplotlibrc`
798800
@@ -827,8 +829,10 @@ def gen_candidates():
827829
yield os.path.join(get_data_path(), 'matplotlibrc')
828830

829831
for fname in gen_candidates():
830-
if os.path.isfile(fname):
831-
break
832+
if os.path.exists(fname):
833+
st_mode = os.stat(fname).st_mode
834+
if stat.S_ISREG(st_mode) or stat.S_ISFIFO(st_mode):
835+
break
832836
# Return first candidate that is a file, or last candidate if none is
833837
# valid (in that case, a warning is raised at startup by `rc_params`).
834838
return fname

0 commit comments

Comments
 (0)