From: Ben Darnell Date: Sun, 7 Mar 2010 20:47:52 +0000 (-0800) Subject: In finish(), test if chunk is None rather than using truthiness to decide X-Git-Tag: v1.0.0~76^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=45f76c518eaf032c40fd39cc1384577742e5dd4d;p=thirdparty%2Ftornado.git In finish(), test if chunk is None rather than using truthiness to decide whether to call write(). This fixes a discrepancy between finish() and write() when outputting json. Now both write({}) and finish({}) will output an empty json object. --- diff --git a/tornado/web.py b/tornado/web.py index 55c6816af..ae7f7f0b3 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -463,7 +463,7 @@ class RequestHandler(object): def finish(self, chunk=None): """Finishes this response, ending the HTTP request.""" assert not self._finished - if chunk: self.write(chunk) + if chunk is not None: self.write(chunk) # Automatically support ETags and add the Content-Length header if # we have not flushed any content yet.