mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Changed a whole bunch of places to raise exception instances instead of old-style raising exception classes plus a comma. Good for the future Python 3 conversion
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12180 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
4
django/core/cache/__init__.py
vendored
4
django/core/cache/__init__.py
vendored
@@ -39,10 +39,10 @@ def parse_backend_uri(backend_uri):
|
||||
(scheme, host, params) tuple.
|
||||
"""
|
||||
if backend_uri.find(':') == -1:
|
||||
raise InvalidCacheBackendError, "Backend URI must start with scheme://"
|
||||
raise InvalidCacheBackendError("Backend URI must start with scheme://")
|
||||
scheme, rest = backend_uri.split(':', 1)
|
||||
if not rest.startswith('//'):
|
||||
raise InvalidCacheBackendError, "Backend URI must start with scheme://"
|
||||
raise InvalidCacheBackendError("Backend URI must start with scheme://")
|
||||
|
||||
host = rest[2:]
|
||||
qpos = rest.find('?')
|
||||
|
||||
2
django/core/cache/backends/base.py
vendored
2
django/core/cache/backends/base.py
vendored
@@ -71,7 +71,7 @@ class BaseCache(object):
|
||||
ValueError exception.
|
||||
"""
|
||||
if key not in self:
|
||||
raise ValueError, "Key '%s' not found" % key
|
||||
raise ValueError("Key '%s' not found" % key)
|
||||
new_value = self.get(key) + delta
|
||||
self.set(key, new_value)
|
||||
return new_value
|
||||
|
||||
2
django/core/cache/backends/filebased.py
vendored
2
django/core/cache/backends/filebased.py
vendored
@@ -129,7 +129,7 @@ class CacheClass(BaseCache):
|
||||
try:
|
||||
os.makedirs(self._dir)
|
||||
except OSError:
|
||||
raise EnvironmentError, "Cache directory '%s' does not exist and could not be created'" % self._dir
|
||||
raise EnvironmentError("Cache directory '%s' does not exist and could not be created'" % self._dir)
|
||||
|
||||
def _key_to_file(self, key):
|
||||
"""
|
||||
|
||||
@@ -34,16 +34,16 @@ class BaseHandler(object):
|
||||
try:
|
||||
dot = middleware_path.rindex('.')
|
||||
except ValueError:
|
||||
raise exceptions.ImproperlyConfigured, '%s isn\'t a middleware module' % middleware_path
|
||||
raise exceptions.ImproperlyConfigured('%s isn\'t a middleware module' % middleware_path)
|
||||
mw_module, mw_classname = middleware_path[:dot], middleware_path[dot+1:]
|
||||
try:
|
||||
mod = import_module(mw_module)
|
||||
except ImportError, e:
|
||||
raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: "%s"' % (mw_module, e)
|
||||
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
|
||||
try:
|
||||
mw_class = getattr(mod, mw_classname)
|
||||
except AttributeError:
|
||||
raise exceptions.ImproperlyConfigured, 'Middleware module "%s" does not define a "%s" class' % (mw_module, mw_classname)
|
||||
raise exceptions.ImproperlyConfigured('Middleware module "%s" does not define a "%s" class' % (mw_module, mw_classname))
|
||||
|
||||
try:
|
||||
mw_instance = mw_class()
|
||||
@@ -113,7 +113,7 @@ class BaseHandler(object):
|
||||
view_name = callback.func_name # If it's a function
|
||||
except AttributeError:
|
||||
view_name = callback.__class__.__name__ + '.__call__' # If it's a class
|
||||
raise ValueError, "The view %s.%s didn't return an HttpResponse object." % (callback.__module__, view_name)
|
||||
raise ValueError("The view %s.%s didn't return an HttpResponse object." % (callback.__module__, view_name))
|
||||
|
||||
return response
|
||||
except http.Http404, e:
|
||||
|
||||
@@ -152,7 +152,7 @@ def call_command(name, *args, **options):
|
||||
else:
|
||||
klass = load_command_class(app_name, name)
|
||||
except KeyError:
|
||||
raise CommandError, "Unknown command: %r" % name
|
||||
raise CommandError("Unknown command: %r" % name)
|
||||
|
||||
# Grab out a list of defaults from the options. optparse does this for us
|
||||
# when the script runs from the command line, but since call_command can
|
||||
|
||||
@@ -530,7 +530,7 @@ class WSGIServer(HTTPServer):
|
||||
try:
|
||||
HTTPServer.server_bind(self)
|
||||
except Exception, e:
|
||||
raise WSGIServerException, e
|
||||
raise WSGIServerException(e)
|
||||
self.setup_environ()
|
||||
|
||||
def setup_environ(self):
|
||||
|
||||
@@ -135,10 +135,10 @@ class RegexURLPattern(object):
|
||||
self._callback = get_callable(self._callback_str)
|
||||
except ImportError, e:
|
||||
mod_name, _ = get_mod_func(self._callback_str)
|
||||
raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e))
|
||||
raise ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e)))
|
||||
except AttributeError, e:
|
||||
mod_name, func_name = get_mod_func(self._callback_str)
|
||||
raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))
|
||||
raise ViewDoesNotExist("Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)))
|
||||
return self._callback
|
||||
callback = property(_get_callback)
|
||||
|
||||
@@ -234,8 +234,8 @@ class RegexURLResolver(object):
|
||||
sub_match_dict[smart_str(k)] = v
|
||||
return sub_match[0], sub_match[1], sub_match_dict
|
||||
tried.append(pattern.regex.pattern)
|
||||
raise Resolver404, {'tried': tried, 'path': new_path}
|
||||
raise Resolver404, {'path' : path}
|
||||
raise Resolver404({'tried': tried, 'path': new_path})
|
||||
raise Resolver404({'path' : path})
|
||||
|
||||
def _get_urlconf_module(self):
|
||||
try:
|
||||
@@ -250,8 +250,7 @@ class RegexURLResolver(object):
|
||||
try:
|
||||
iter(patterns)
|
||||
except TypeError:
|
||||
raise ImproperlyConfigured("The included urlconf %s doesn't have any "
|
||||
"patterns in it" % self.urlconf_name)
|
||||
raise ImproperlyConfigured("The included urlconf %s doesn't have any patterns in it" % self.urlconf_name)
|
||||
return patterns
|
||||
url_patterns = property(_get_url_patterns)
|
||||
|
||||
@@ -260,7 +259,7 @@ class RegexURLResolver(object):
|
||||
try:
|
||||
return get_callable(callback), {}
|
||||
except (ImportError, AttributeError), e:
|
||||
raise ViewDoesNotExist, "Tried %s. Error was: %s" % (callback, str(e))
|
||||
raise ViewDoesNotExist("Tried %s. Error was: %s" % (callback, str(e)))
|
||||
|
||||
def resolve404(self):
|
||||
return self._resolve_special('404')
|
||||
|
||||
Reference in New Issue
Block a user