diff --git a/webapp2.py b/webapp2.py index e48e7bf..28106ab 100755 --- a/webapp2.py +++ b/webapp2.py @@ -416,11 +416,8 @@ 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, six.string_types): - text = six.text_type(text) + if not isinstance(text, (six.text_type, six.binary_type)): + text = str(text) if isinstance(text, six.text_type) and not self.charset: self.charset = self.default_charset