Author: jezdez
Date: 2011-04-22 05:15:52 -0700 (Fri, 22 Apr 2011)
New Revision: 16082

Modified:
   django/trunk/django/core/handlers/modpython.py
   django/trunk/django/core/handlers/wsgi.py
   django/trunk/tests/regressiontests/handlers/tests.py
Log:
Fixed #15672 -- Refined changes made in r15918. Thanks, vung.

Modified: django/trunk/django/core/handlers/modpython.py
===================================================================
--- django/trunk/django/core/handlers/modpython.py      2011-04-22 12:14:54 UTC 
(rev 16081)
+++ django/trunk/django/core/handlers/modpython.py      2011-04-22 12:15:52 UTC 
(rev 16082)
@@ -179,11 +179,10 @@
             try:
                 request = self.request_class(req)
             except UnicodeDecodeError:
-                logger.warning('Bad Request (UnicodeDecodeError): %s' % 
request.path,
+                logger.warning('Bad Request (UnicodeDecodeError)',
                     exc_info=sys.exc_info(),
                     extra={
                         'status_code': 400,
-                        'request': request
                     }
                 )
                 response = http.HttpResponseBadRequest()

Modified: django/trunk/django/core/handlers/wsgi.py
===================================================================
--- django/trunk/django/core/handlers/wsgi.py   2011-04-22 12:14:54 UTC (rev 
16081)
+++ django/trunk/django/core/handlers/wsgi.py   2011-04-22 12:15:52 UTC (rev 
16082)
@@ -265,7 +265,6 @@
                     exc_info=sys.exc_info(),
                     extra={
                         'status_code': 400,
-                        'request': request
                     }
                 )
                 response = http.HttpResponseBadRequest()

Modified: django/trunk/tests/regressiontests/handlers/tests.py
===================================================================
--- django/trunk/tests/regressiontests/handlers/tests.py        2011-04-22 
12:14:54 UTC (rev 16081)
+++ django/trunk/tests/regressiontests/handlers/tests.py        2011-04-22 
12:15:52 UTC (rev 16082)
@@ -1,7 +1,9 @@
 from django.utils import unittest
 from django.conf import settings
 from django.core.handlers.wsgi import WSGIHandler
+from django.test import RequestFactory
 
+
 class HandlerTests(unittest.TestCase):
 
     def test_lock_safety(self):
@@ -23,3 +25,10 @@
         # Reset settings
         settings.MIDDLEWARE_CLASSES = old_middleware_classes
 
+    def test_bad_path_info(self):
+        """Tests for bug #15672 ('request' referenced before assignment)"""
+        environ = RequestFactory().get('/').environ
+        environ['PATH_INFO'] = '\xed'
+        handler = WSGIHandler()
+        response = handler(environ, lambda *a, **k: None)
+        self.assertEqual(response.status_code, 400)

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to