diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index 7541a5fd9d..5120ef6637 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -55,9 +55,30 @@ class WSGIRequest(httpwrappers.HttpRequest): def __repr__(self): from pprint import pformat - return '' % \ - (pformat(self.GET), pformat(self.POST), pformat(self.COOKIES), - pformat(self.META)) + # Since this is called as part of error handling, we need to be very + # robust against potentially malformed input. + try: + get = pformat(self.GET) + except: + get = '' + try: + post = pformat(self.POST) + except: + post = '' + try: + cookies = pformat(self.COOKIES) + except: + cookies = '' + try: + meta = pformat(self.META) + except: + meta = '' + try: + user = self.user + except: + user = '' + return '' % \ + (self.path, get, post, cookies, meta, user) def get_full_path(self): return '%s%s' % (self.path, self.environ['QUERY_STRING'] and ('?' + self.environ['QUERY_STRING']) or '')