mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #6170 -- Ensured that a useful exception is raised when a regex is invalid in the URLConf.
Thanks to abrahamson.j for the report, to guettli for initial work on the patch, and to David Gouldin for the new patch and test.
This commit is contained in:
@@ -160,10 +160,16 @@ class LocaleRegexProvider(object):
|
||||
language_code = get_language()
|
||||
if language_code not in self._regex_dict:
|
||||
if isinstance(self._regex, basestring):
|
||||
compiled_regex = re.compile(self._regex, re.UNICODE)
|
||||
regex = self._regex
|
||||
else:
|
||||
regex = force_unicode(self._regex)
|
||||
try:
|
||||
compiled_regex = re.compile(regex, re.UNICODE)
|
||||
except re.error, e:
|
||||
raise ImproperlyConfigured(
|
||||
u'"%s" is not a valid regular expression: %s' %
|
||||
(regex, unicode(e)))
|
||||
|
||||
self._regex_dict[language_code] = compiled_regex
|
||||
return self._regex_dict[language_code]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user