diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
index 625ec63..58213a3 100644
a
|
b
|
class LocaleRegexProvider(object):
|
160 | 160 | language_code = get_language() |
161 | 161 | if language_code not in self._regex_dict: |
162 | 162 | if isinstance(self._regex, basestring): |
163 | | compiled_regex = re.compile(self._regex, re.UNICODE) |
| 163 | regex = self._regex |
164 | 164 | else: |
165 | 165 | regex = force_unicode(self._regex) |
| 166 | try: |
166 | 167 | compiled_regex = re.compile(regex, re.UNICODE) |
| 168 | except re.error, e: |
| 169 | raise ImproperlyConfigured( |
| 170 | u'"%s" is not a valid regular expression: %s' % |
| 171 | (regex, unicode(e))) |
| 172 | |
167 | 173 | self._regex_dict[language_code] = compiled_regex |
168 | 174 | return self._regex_dict[language_code] |
169 | 175 | |
diff --git a/tests/regressiontests/urlpatterns_reverse/erroneous_urls.py b/tests/regressiontests/urlpatterns_reverse/erroneous_urls.py
index 8e6433e..e1ef5b2 100644
a
|
b
|
urlpatterns = patterns('',
|
11 | 11 | url(r'uncallable/$', 'regressiontests.urlpatterns_reverse.views.uncallable'), |
12 | 12 | # Module does not exist |
13 | 13 | url(r'missing_outer/$', 'regressiontests.urlpatterns_reverse.missing_module.missing_view'), |
| 14 | # Regex contains an error |
| 15 | url(r'(regex_error/$', 'regressiontestes.urlpatterns_reverse.views.empty_view'), |
14 | 16 | ) |
diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py
index bb25806..eeb83de 100644
a
|
b
|
class ErroneousViewTests(TestCase):
|
511 | 511 | self.assertRaises(ViewDoesNotExist, self.client.get, '/missing_outer/') |
512 | 512 | self.assertRaises(ViewDoesNotExist, self.client.get, '/uncallable/') |
513 | 513 | |
| 514 | def test_erroneous_reverse(self): |
| 515 | # The regex error will be hit before NoReverseMatch can be raised |
| 516 | self.assertRaises(ImproperlyConfigured, reverse, 'asdf') |
| 517 | |