diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-03 23:01:47 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-07 12:00:24 +0200 |
| commit | bf4da7a4420ccacf76090301a1e0efa1eea17751 (patch) | |
| tree | 50a6b63ce34b75cc4348f6671399691d7adbd75a | |
| parent | 9e0a10ba77ad1737c4aaf49e5d4b4380f912bc0e (diff) | |
[py3] Made a small fix in django.http.
This is necessary for the 'utils' tests to pass.
| -rw-r--r-- | django/http/__init__.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py index b23304f346..d559fdf7c6 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -549,7 +549,12 @@ class HttpResponse(object): 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 |
