From 38a6c48878c4318fac404e6ee2454d78b26c098b Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Fri, 8 May 2009 11:31:36 +0000 Subject: [PATCH] Fixed a silly function flow bug in [10711]. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10712 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/http/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/django/http/__init__.py b/django/http/__init__.py index 92c38c0ad6..683212fcd4 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -304,16 +304,17 @@ class HttpResponse(object): def _convert_to_ascii(self, *values): """Converts all values to ascii strings.""" for value in values: - if '\n' in value or '\r' in value: - raise BadHeaderError("Header values can't contain newlines (got %r)" % (value)) if isinstance(value, unicode): try: - yield value.encode('us-ascii') + value = value.encode('us-ascii') except UnicodeError, e: e.reason += ', HTTP response headers must be in US-ASCII format' raise else: - yield str(value) + value = str(value) + if '\n' in value or '\r' in value: + raise BadHeaderError("Header values can't contain newlines (got %r)" % (value)) + yield value def __setitem__(self, header, value): header, value = self._convert_to_ascii(header, value)