Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions webapp2.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,12 @@ def write(self, text):
"""Appends a text to the response body."""
# webapp uses StringIO as Response.out, so we need to convert anything
# that is not str or unicode to string to keep same behavior.
if six.PY3 and isinstance(text, bytes):
text = text.decode(self.default_charset)
if not isinstance(text, bytes):
if not isinstance(text, six.string_types):
text = six.text_type(text)

if not isinstance(text, six.string_types):
text = six.text_type(text)

if isinstance(text, six.text_type) and not self.charset:
self.charset = self.default_charset
if isinstance(text, six.text_type) and not self.charset:
self.charset = self.default_charset

super(Response, self).write(text)

Expand Down