From ef9f48e578a14c91fb101a4fbe73e5c3d400dcbf Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Thu, 26 Mar 2009 22:04:05 +0000 Subject: [PATCH] Simplify complex expression. --- Lib/http/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/http/client.py b/Lib/http/client.py index b1b76c283b4..0477ddd2d1b 100644 --- a/Lib/http/client.py +++ b/Lib/http/client.py @@ -906,7 +906,9 @@ class HTTPConnection: self._set_content_length(body) for hdr, value in headers.items(): self.putheader(hdr, value) - self.endheaders(body.encode('ascii') if isinstance(body, str) else body) + if isinstance(body, str): + body = body.encode('ascii') + self.endheaders(body) def getresponse(self): """Get the response from the server."""