Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 21921a3

Browse filesBrowse files
committed
get_configdir returns None if tempfile.gettempdir() is not available.
Previously, it would raise NotImplementedError. This is necessary on restricted platforms such as Google App Engine that do not provide gettempdir.
1 parent 4d65400 commit 21921a3
Copy full SHA for 21921a3

File tree

Expand file treeCollapse file tree

1 file changed

+12
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-3
lines changed

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,19 @@ def _create_tmp_config_dir():
495495
"""
496496
If the config directory can not be created, create a temporary
497497
directory.
498+
499+
Returns None if a writable temporary directory could not be created.
498500
"""
499501
import getpass
500502
import tempfile
501503

502-
tempdir = os.path.join(
503-
tempfile.gettempdir(), 'matplotlib-%s' % getpass.getuser())
504+
try:
505+
tempdir = tempfile.gettempdir()
506+
except NotImplementedError:
507+
# Some restricted platforms (such as Google App Engine) do not provide
508+
# gettempdir.
509+
return None
510+
tempdir = os.path.join(tempdir, 'matplotlib-%s' % getpass.getuser())
504511
os.environ['MPLCONFIGDIR'] = tempdir
505512

506513
return tempdir
@@ -519,7 +526,9 @@ def _get_configdir():
519526
create it if necessary).
520527
2. If the chosen directory exists and is writable, use that as the
521528
configuration directory.
522-
3. Create a temporary directory, and use it as the configuration directory.
529+
3. If possible, create a temporary directory, and use it as the
530+
configuration directory.
531+
4. A writable directory could not be found or created; return None.
523532
"""
524533

525534
configdir = os.environ.get('MPLCONFIGDIR')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.