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
This commit is contained in:
parent
cc22693505
commit
1fd9b44a6b
|
@ -351,7 +351,10 @@ class HttpResponse(HttpResponseBase):
|
||||||
@content.setter
|
@content.setter
|
||||||
def content(self, value):
|
def content(self, value):
|
||||||
# Consume iterators upon assignment to allow repeated iteration.
|
# 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)
|
content = b''.join(self.make_bytes(chunk) for chunk in value)
|
||||||
if hasattr(value, 'close'):
|
if hasattr(value, 'close'):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue