Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#24360 closed Bug (fixed)

when LocaleMiddleware activated, no error page with traceback and error message in logger

Reported by: mishust Owned by: Claude Paroz <claude@…>
Component: Core (Other) Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by mishust)

Steps to reproduce:

  1. include in MIDDLEWARE_CLASSES

'django.middleware.locale.LocaleMiddleware',

  1. Make error in code (for example addind 'f' symbol)

urlpatterns = patterns(,
f
url(r'admin/', include(admin.site.urls)),

  1. Open root page http://mysite/

Result: "A server error occurred. Please contact the administrator." HTML page
and Traceback on concole output

Expected result: with Debug=True expecting to see HTML error page with Traceback and detailed info.

Also, error message dont appear in python logger - in files, not send to ADMIN emails.

Change History (10)

comment:1 by mishust, 10 years ago

Description: modified (diff)

comment:3 by Grzegorz Ślusarek, 10 years ago

Owner: changed from nobody to Grzegorz Ślusarek
Status: newassigned

comment:4 by Grzegorz Ślusarek, 10 years ago

Owner: Grzegorz Ślusarek removed
Status: assignednew

comment:5 by Claude Paroz, 10 years ago

Component: UncategorizedCore (Other)
Triage Stage: UnreviewedAccepted

comment:6 by Claude Paroz, 10 years ago

Has patch: set

The problem appears when a middleware fails in its __init__ method. In the LocaleMiddleware use case, it can easily be workarounded by transforming is_language_prefix_patterns_used into a cached property, like this:
https://github.com/django/django/pull/4224

comment:7 by Tim Graham, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Claude Paroz <claude@…>, 10 years ago

Owner: set to Claude Paroz <claude@…>
Resolution: fixed
Status: newclosed

In 80be597a7b2530ec0893e1d9ee8275e281f026dc:

Fixed #24360 -- Delayed internal LocaleMiddleware variable initialization

Failing in a middleware __init__ is preventing proper debug view.

comment:9 by Peter J. Farrell, 10 years ago

Just wanted to add to this ticket for those stuck with django.db.utils.OperationalError: SSL SYSCALL errors. Using the fix in master (which I assume will be in 1.7.6) fixes the issue.

 00:50:04.391  2015-03-06 06:50:04.020323+00:00 app web.1     - - Traceback (most recent call last):
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 168, in __call__
    self.load_middleware()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 46, in load_middleware
    mw_instance = mw_class()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/middleware/locale.py", line 23, in __init__
    for url_pattern in get_resolver(None).url_patterns:
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 372, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/urlresolvers.py", line 366, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "./verde/urls.py", line 22, in <module>
    (r'^verdeadmin/', include(admin.site.urls)),
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 262, in urls
    return self.get_urls(), self.app_name, self.name
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 246, in get_urls
    url(r'^%s/%s/' % (model._meta.app_label, model._meta.model_name), include(model_admin.urls))
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/options.py", line 598, in urls
    return self.get_urls()
  File "/app/.heroku/python/lib/python2.7/site-packages/cms/admin/pageadmin.py", line 145, in get_urls
    url_patterns += super(PageAdmin, self).get_urls()
  File "/app/.heroku/python/lib/python2.7/site-packages/cms/admin/placeholderadmin.py", line 131, in get_urls
    from cms.urls import SLUG_REGEXP
  File "/app/.heroku/python/lib/python2.7/site-packages/cms/urls.py", line 20, in <module>
    urlpatterns = get_app_patterns()
  File "/app/.heroku/python/lib/python2.7/site-packages/cms/appresolver.py", line 191, in get_app_patterns
    current_site = Site.objects.get_current()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/sites/models.py", line 54, in get_current
    current_site = self.get(pk=sid)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/manager.py", line 92, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.py", line 351, in get
    num = len(clone)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.py", line 122, in __len__
    self._fetch_all()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.py", line 966, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.py", line 265, in iterator
    for row in compiler.results_iter():
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 700, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.db.utils.OperationalError: SSL SYSCALL error: EOF detected Exception

comment:10 by Claude Paroz, 10 years ago

Note that this has only been committed to the master branch (targeting 1.9).

Note: See TracTickets for help on using tickets.
Back to Top