Skip to content
Browse files

[py3] Made a small fix in django.http.

This is necessary for the 'utils' tests to pass.
  • Loading branch information...
1 parent 9e0a10b commit bf4da7a4420ccacf76090301a1e0efa1eea17751 @aaugustin aaugustin committed Aug 3, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 django/http/__init__.py
View
7 django/http/__init__.py
@@ -549,7 +549,12 @@ def _convert_to_ascii(self, *values):
for value in values:
if isinstance(value, six.text_type):
try:
- value = value.encode('us-ascii')
+ if not six.PY3:
+ value = value.encode('us-ascii')
+ else:
+ # In Python 3, use a string in headers,
+ # but ensure in only contains ASCII characters.
+ value.encode('us-ascii')
except UnicodeError as e:
e.reason += ', HTTP response headers must be in US-ASCII format'
raise

0 comments on commit bf4da7a

Please sign in to comment.
Something went wrong with that request. Please try again.