From: Ben Darnell Date: Sat, 23 Mar 2019 15:11:18 +0000 (-0400) Subject: httpclient: HTTPResponse.body returns empty string instead of raising X-Git-Tag: v6.0.2^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=317c4d02306663fd2edff0b33a9da2a300f2c534;p=thirdparty%2Ftornado.git httpclient: HTTPResponse.body returns empty string instead of raising In tornado 5, HTTPResponse.body would return None if there was no body buffer (which included errors like timeouts and socket errors, but not HTTP errors like 404). In tornado 6 this was changed to never return None (to make it easier to work with type annotations) and raise an error instead. This turned out to be disruptive, so change it back to returning a value without raising (but now it's an empty byte string instead of None). Fixes #2626 --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 33abe2e16..882600af8 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -665,7 +665,7 @@ class HTTPResponse(object): @property def body(self) -> bytes: if self.buffer is None: - raise ValueError("body not set") + return b"" elif self._body is None: self._body = self.buffer.getvalue()