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