Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a silly function flow bug in [10711].

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10712 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 38a6c48878c4318fac404e6ee2454d78b26c098b 1 parent 155ab07
Jacob Kaplan-Moss jacobian authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 django/http/__init__.py
9 django/http/__init__.py
View
@@ -304,16 +304,17 @@ def __str__(self):
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)
Please sign in to comment.
Something went wrong with that request. Please try again.