@@ -213,28 +213,7 @@ def _is_writable_dir(p):
213213 p is a string pointing to a putative writable dir -- return True p
214214 is such a string, else False
215215 """
216- try :
217- p + '' # test is string like
218- except TypeError :
219- return False
220-
221- # Test whether the operating system thinks it's a writable directory.
222- # Note that this check is necessary on Google App Engine, because the
223- # subsequent check will succeed even though p may not be writable.
224- if not os .access (p , os .W_OK ) or not os .path .isdir (p ):
225- return False
226-
227- # Also test that it is actually possible to write to a file here.
228- try :
229- t = tempfile .TemporaryFile (dir = p )
230- try :
231- t .write (b'1' )
232- finally :
233- t .close ()
234- except :
235- return False
236-
237- return True
216+ return os .access (p , os .W_OK ) and os .path .isdir (p )
238217
239218
240219class Verbose (object ):
@@ -510,17 +489,12 @@ def _get_home():
510489 :see:
511490 http://mail.python.org/pipermail/python-list/2005-February/325395.html
512491 """
513- try :
514- if six .PY2 and sys .platform == 'win32' :
515- path = os .path .expanduser (b"~" ).decode (sys .getfilesystemencoding ())
516- else :
517- path = os .path .expanduser ("~" )
518- except ImportError :
519- # This happens on Google App Engine (pwd module is not present).
520- pass
492+ if six .PY2 and sys .platform == 'win32' :
493+ path = os .path .expanduser (b"~" ).decode (sys .getfilesystemencoding ())
521494 else :
522- if os .path .isdir (path ):
523- return path
495+ path = os .path .expanduser ("~" )
496+ if os .path .isdir (path ):
497+ return path
524498 for evar in ('HOME' , 'USERPROFILE' , 'TMP' ):
525499 path = os .environ .get (evar )
526500 if path is not None and os .path .isdir (path ):
@@ -532,17 +506,9 @@ def _create_tmp_config_dir():
532506 """
533507 If the config directory can not be created, create a temporary
534508 directory.
535-
536- Returns None if a writable temporary directory could not be created.
537509 """
538- try :
539- tempdir = tempfile .gettempdir ()
540- except NotImplementedError :
541- # Some restricted platforms (such as Google App Engine) do not provide
542- # gettempdir.
543- return None
544510 configdir = os .environ ['MPLCONFIGDIR' ] = (
545- tempfile .mkdtemp (prefix = 'matplotlib-' , dir = tempdir ))
511+ tempfile .mkdtemp (prefix = 'matplotlib-' ))
546512 return configdir
547513
548514
0 commit comments