diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-07-21 10:00:10 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-08-07 12:00:22 +0200 |
| commit | c5ef65bcf324f4c90b53be90f4aec069a68e8c59 (patch) | |
| tree | bb9a4988fbae4e7366cc578ca845c49003cdcd64 /django/http/multipartparser.py | |
| parent | ee191715eae73362768184aa95206cf61bac5d38 (diff) | |
[py3] Ported django.utils.encoding.
* Renamed smart_unicode to smart_text (but kept the old name under
Python 2 for backwards compatibility).
* Renamed smart_str to smart_bytes.
* Re-introduced smart_str as an alias for smart_text under Python 3
and smart_bytes under Python 2 (which is backwards compatible).
Thus smart_str always returns a str objects.
* Used the new smart_str in a few places where both Python 2 and 3
want a str.
Diffstat (limited to 'django/http/multipartparser.py')
| -rw-r--r-- | django/http/multipartparser.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py index 0e28a55c3a..1987ee53bc 100644 --- a/django/http/multipartparser.py +++ b/django/http/multipartparser.py @@ -10,7 +10,7 @@ import cgi from django.conf import settings from django.core.exceptions import SuspiciousOperation from django.utils.datastructures import MultiValueDict -from django.utils.encoding import force_unicode +from django.utils.encoding import force_text from django.utils import six from django.utils.text import unescape_entities from django.core.files.uploadhandler import StopUpload, SkipFile, StopFutureHandlers @@ -151,7 +151,7 @@ class MultiPartParser(object): transfer_encoding = meta_data.get('content-transfer-encoding') if transfer_encoding is not None: transfer_encoding = transfer_encoding[0].strip() - field_name = force_unicode(field_name, encoding, errors='replace') + field_name = force_text(field_name, encoding, errors='replace') if item_type == FIELD: # This is a post field, we can just set it in the post @@ -165,13 +165,13 @@ class MultiPartParser(object): data = field_stream.read() self._post.appendlist(field_name, - force_unicode(data, encoding, errors='replace')) + force_text(data, encoding, errors='replace')) elif item_type == FILE: # This is a file, use the handler... file_name = disposition.get('filename') if not file_name: continue - file_name = force_unicode(file_name, encoding, errors='replace') + file_name = force_text(file_name, encoding, errors='replace') file_name = self.IE_sanitize(unescape_entities(file_name)) content_type = meta_data.get('content-type', ('',))[0].strip() @@ -245,7 +245,7 @@ class MultiPartParser(object): file_obj = handler.file_complete(counters[i]) if file_obj: # If it returns a file object, then set the files dict. - self._files.appendlist(force_unicode(old_field_name, + self._files.appendlist(force_text(old_field_name, self._encoding, errors='replace'), file_obj) |
