diff --git a/CHANGES.rst b/CHANGES.rst index bf71854c4b..edac84affb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -38,7 +38,6 @@ https://github.com/zopefoundation/Zope/blob/4.x/CHANGES.rst For details, see `#1202 `_. -- Small optimization when encoding the response body. 5.9 (2023-11-24) ---------------- diff --git a/src/ZPublisher/HTTPResponse.py b/src/ZPublisher/HTTPResponse.py index 9967cd9b8f..264a488a03 100644 --- a/src/ZPublisher/HTTPResponse.py +++ b/src/ZPublisher/HTTPResponse.py @@ -552,9 +552,7 @@ def setBody(self, body, title='', is_error=False, lock=None): except (TypeError, UnicodeError): pass if not isinstance(body, bytes): - if not isinstance(body, str): - body = str(body) - body = self._encode_unicode(body) + body = self._encode_unicode(str(body)) # At this point body is always binary b_len = len(body)