diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-08-17 17:32:31 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-08-17 17:32:31 +0000 |
| commit | 98be84154942789e498d8717c8d25f378ca456b1 (patch) | |
| tree | 9228b83bc17c638fa2e8105bf89a657b7460552c /django/db/__init__.py | |
| parent | a80a5ae46f0a34d73c381f425ba3aa68709ae03b (diff) | |
Fixed #8238 -- If an invalid database backend is mentioned in settings and the
environment doesn't support os.listdir(), we crashed whilst trying to construct
the friendly error message. This was not so friendly.
This patch handles that case (which occurs in real life in Google App Engine).
Patch from Guido van Rossum.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8424 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/__init__.py')
| -rw-r--r-- | django/db/__init__.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/__init__.py b/django/db/__init__.py index 58d66b02c8..d15fd3238e 100644 --- a/django/db/__init__.py +++ b/django/db/__init__.py @@ -24,7 +24,10 @@ except ImportError, e: # The database backend wasn't found. Display a helpful error message # listing all possible (built-in) database backends. backend_dir = os.path.join(__path__[0], 'backends') - available_backends = [f for f in os.listdir(backend_dir) if not f.startswith('_') and not f.startswith('.') and not f.endswith('.py') and not f.endswith('.pyc')] + try: + available_backends = [f for f in os.listdir(backend_dir) if not f.startswith('_') and not f.startswith('.') and not f.endswith('.py') and not f.endswith('.pyc')] + except EnvironmentError: + available_backends = [] available_backends.sort() if settings.DATABASE_ENGINE not in available_backends: raise ImproperlyConfigured, "%r isn't an available database backend. Available options are: %s\nError was: %s" % \ |
