Ticket #15672: ticket-15672.diff

File ticket-15672.diff, 2.1 KB (added by vung, 14 years ago)

Removes references to request in the wsgi and mod_python handlers and adds a test

  • django/core/handlers/wsgi.py

     
    265265                    exc_info=sys.exc_info(),
    266266                    extra={
    267267                        'status_code': 400,
    268                         'request': request
    269268                    }
    270269                )
    271270                response = http.HttpResponseBadRequest()
  • django/core/handlers/modpython.py

     
    179179            try:
    180180                request = self.request_class(req)
    181181            except UnicodeDecodeError:
    182                 logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path,
     182                logger.warning('Bad Request (UnicodeDecodeError)',
    183183                    exc_info=sys.exc_info(),
    184184                    extra={
    185185                        'status_code': 400,
    186                         'request': request
    187186                    }
    188187                )
    189188                response = http.HttpResponseBadRequest()
  • tests/regressiontests/handlers/tests.py

     
    11from django.utils import unittest
    22from django.conf import settings
    33from django.core.handlers.wsgi import WSGIHandler
     4from django.test import RequestFactory
    45
     6
    57class HandlerTests(unittest.TestCase):
    68
    79    def test_lock_safety(self):
     
    2325        # Reset settings
    2426        settings.MIDDLEWARE_CLASSES = old_middleware_classes
    2527
     28    def test_bad_path_info(self):
     29        """Tests for bug #15672 ('request' referenced before assignment)"""
     30        environ = RequestFactory().get('/').environ
     31        environ['PATH_INFO'] = '\xed'
     32        handler = WSGIHandler()
     33        response = handler(environ, lambda *a, **k: None)
     34        self.assertEqual(response.status_code, 400)
Back to Top