Fix werkzeug.wrappers.BaseResponse.__init__ (#2232)

This additionally allows strings, bytearrays and string iterables to be
passed as the `response` argument of `BaseResponse` (and thus also
`Response`).

Strings and bytearrays are explicitly handled in `__init__` [1].
Strings are also featured on the Werkzeug front-page snippet (`'Hello
World!'`) [2].

[1]: d129d17066/werkzeug/wrappers.py (L861)
[2]: http://werkzeug.pocoo.org/
This commit is contained in:
Bertrand Bonnefoy-Claudet
2018-06-15 16:24:22 +02:00
committed by Jelle Zijlstra
parent 15ad132393
commit 4b5a63d10f

View File

@@ -84,7 +84,7 @@ class BaseResponse:
status = ... # type: str
direct_passthrough = ... # type: bool
response = ... # type: Iterable[bytes]
def __init__(self, response: Optional[Union[Iterable[bytes], bytes]] = ...,
def __init__(self, response: Optional[Union[str, bytes, bytearray, Iterable[str], Iterable[bytes]]] = ...,
status: Optional[Union[Text, int]] = ...,
headers: Optional[Union[Headers,
Mapping[Text, Text],