summaryrefslogtreecommitdiff
path: root/django/http
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-11-06 12:34:50 +0100
committerCarlton Gibson <carlton@noumenal.es>2020-11-10 09:56:15 +0100
commit1fd9b44a6b1bde29fb1f6746e007787505608974 (patch)
tree9114c53ab2df1752911395ed30a508d7f7358812 /django/http
parentcc2269350548307e3fe31723ff4e40a879a7a173 (diff)
Refs #32074 -- Fixed handling memoryview content by HttpResponse on Python 3.10+.
An iterator was added to memoryview in Python 3.10, see https://bugs.python.org/issue41732 Refs #30294
Diffstat (limited to 'django/http')
-rw-r--r--django/http/response.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/http/response.py b/django/http/response.py
index eedc03f118..91d4ddc880 100644
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -351,7 +351,10 @@ class HttpResponse(HttpResponseBase):
@content.setter
def content(self, value):
# Consume iterators upon assignment to allow repeated iteration.
- if hasattr(value, '__iter__') and not isinstance(value, (bytes, str)):
+ if (
+ hasattr(value, '__iter__') and
+ not isinstance(value, (bytes, memoryview, str))
+ ):
content = b''.join(self.make_bytes(chunk) for chunk in value)
if hasattr(value, 'close'):
try: