diff options
| author | Claude Paroz <claude@2xlibre.net> | 2017-01-20 10:20:53 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2017-01-20 14:13:55 +0100 |
| commit | 042b7350a080cc964f913faf1cf7f0097f650a58 (patch) | |
| tree | 4ad77d8fc8ae016770afe01a543a6042fa02357a /django/http | |
| parent | 4e729feaa647547f25debb1cb63dec989dc41a20 (diff) | |
Refs #23919 -- Removed unneeded str() calls
Diffstat (limited to 'django/http')
| -rw-r--r-- | django/http/cookie.py | 8 | ||||
| -rw-r--r-- | django/http/request.py | 4 | ||||
| -rw-r--r-- | django/http/response.py | 3 |
3 files changed, 7 insertions, 8 deletions
diff --git a/django/http/cookie.py b/django/http/cookie.py index fb0a7786ef..36945ce106 100644 --- a/django/http/cookie.py +++ b/django/http/cookie.py @@ -22,13 +22,13 @@ def parse_cookie(cookie): Return a dictionary parsed from a `Cookie:` header string. """ cookiedict = {} - for chunk in cookie.split(str(';')): - if str('=') in chunk: - key, val = chunk.split(str('='), 1) + for chunk in cookie.split(';'): + if '=' in chunk: + key, val = chunk.split('=', 1) else: # Assume an empty name per # https://bugzilla.mozilla.org/show_bug.cgi?id=169091 - key, val = str(''), chunk + key, val = '', chunk key, val = key.strip(), val.strip() if key or val: # unquote using Python's algorithm. diff --git a/django/http/request.py b/django/http/request.py index 6f3b0c9951..554e05217d 100644 --- a/django/http/request.py +++ b/django/http/request.py @@ -509,11 +509,11 @@ class QueryDict(MultiValueDict): # this slightly more restricted function, used by QueryDict. def bytes_to_text(s, encoding): """ - Converts basestring objects to unicode, using the given encoding. Illegally + Convert bytes objects to strings, using the given encoding. Illegally encoded input characters are replaced with Unicode "unknown" codepoint (\ufffd). - Returns any non-basestring objects without change. + Return any non-bytes objects without change. """ if isinstance(s, bytes): return str(s, encoding, 'replace') diff --git a/django/http/response.py b/django/http/response.py index e992adaed5..9c697f5b88 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -124,8 +124,7 @@ class HttpResponseBase: value = value.decode(charset) except UnicodeError as e: if mime_encode: - # Wrapping in str() is a workaround for #12422 under Python 2. - value = str(Header(value, 'utf-8', maxlinelen=sys.maxsize).encode()) + value = Header(value, 'utf-8', maxlinelen=sys.maxsize).encode() else: e.reason += ', HTTP response headers must be in %s format' % charset raise |
