summaryrefslogtreecommitdiff
path: root/django/core/handlers/modpython.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/core/handlers/modpython.py')
-rw-r--r--django/core/handlers/modpython.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py
index 17e739600c..395ec65314 100644
--- a/django/core/handlers/modpython.py
+++ b/django/core/handlers/modpython.py
@@ -1,5 +1,7 @@
+import logging
import os
from pprint import pformat
+import sys
from warnings import warn
from django import http
@@ -9,6 +11,9 @@ from django.core.urlresolvers import set_script_prefix
from django.utils import datastructures
from django.utils.encoding import force_unicode, smart_str, iri_to_uri
+logger = logging.getLogger('django.request')
+
+
# NOTE: do *not* import settings (or any module which eventually imports
# settings) until after ModPythonHandler has been called; otherwise os.environ
# won't be set up correctly (with respect to settings).
@@ -200,6 +205,13 @@ class ModPythonHandler(BaseHandler):
try:
request = self.request_class(req)
except UnicodeDecodeError:
+ logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path,
+ exc_info=sys.exc_info(),
+ extra={
+ 'status_code': 400,
+ 'request': request
+ }
+ )
response = http.HttpResponseBadRequest()
else:
response = self.get_response(request)