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