Refs #27795 -- Replaced force_bytes() usage in django.http.
This commit is contained in:
parent
fa75b2cb51
commit
7d96f0c49a
|
@ -14,7 +14,7 @@ from django.core.files import uploadhandler
|
|||
from django.http.multipartparser import MultiPartParser, MultiPartParserError
|
||||
from django.utils.datastructures import ImmutableList, MultiValueDict
|
||||
from django.utils.deprecation import RemovedInDjango30Warning
|
||||
from django.utils.encoding import escape_uri_path, force_bytes, iri_to_uri
|
||||
from django.utils.encoding import escape_uri_path, iri_to_uri
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.http import is_same_domain, limited_parse_qsl
|
||||
|
||||
|
@ -511,7 +511,7 @@ class QueryDict(MultiValueDict):
|
|||
"""
|
||||
output = []
|
||||
if safe:
|
||||
safe = force_bytes(safe, self.encoding)
|
||||
safe = safe.encode(self.encoding)
|
||||
|
||||
def encode(k, v):
|
||||
return '%s=%s' % ((quote(k, safe), quote(v, safe)))
|
||||
|
@ -519,9 +519,10 @@ class QueryDict(MultiValueDict):
|
|||
def encode(k, v):
|
||||
return urlencode({k: v})
|
||||
for k, list_ in self.lists():
|
||||
k = force_bytes(k, self.encoding)
|
||||
output.extend(encode(k, force_bytes(v, self.encoding))
|
||||
for v in list_)
|
||||
output.extend(
|
||||
encode(k.encode(self.encoding), v.encode(self.encoding))
|
||||
for v in list_
|
||||
)
|
||||
return '&'.join(output)
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.core.exceptions import DisallowedRedirect
|
|||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.http.cookie import SimpleCookie
|
||||
from django.utils import timezone
|
||||
from django.utils.encoding import force_bytes, iri_to_uri
|
||||
from django.utils.encoding import iri_to_uri
|
||||
from django.utils.http import http_date
|
||||
|
||||
_charset_from_content_type_re = re.compile(r';\s*charset=(?P<charset>[^\s;]+)', re.I)
|
||||
|
@ -228,9 +228,8 @@ class HttpResponseBase:
|
|||
return bytes(value)
|
||||
if isinstance(value, str):
|
||||
return bytes(value.encode(self.charset))
|
||||
|
||||
# Handle non-string types (#16494)
|
||||
return force_bytes(value, self.charset)
|
||||
# Handle non-string types.
|
||||
return str(value).encode(self.charset)
|
||||
|
||||
# These methods partially implement the file-like object interface.
|
||||
# See https://docs.python.org/3/library/io.html#io.IOBase
|
||||
|
|
Loading…
Reference in New Issue