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

Skip to content

Commit 244e8d8

Browse files
committed
Don't pretend to support Google App Engine.
It's broken further down anyways: see discussion starting at https://gitter.im/matplotlib/matplotlib?at=59777c5e1c8697534a5be4cb If we want to restore this functionality it should be correctly tested.
1 parent a5d9254 commit 244e8d8

File tree

1 file changed

+7
-41
lines changed

1 file changed

+7
-41
lines changed

lib/matplotlib/__init__.py

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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

239218
class 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

Comments
 (0)