]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
In finish(), test if chunk is None rather than using truthiness to decide
authorBen Darnell <bdarnell@beaker.local>
Sun, 7 Mar 2010 20:47:52 +0000 (12:47 -0800)
committerBen Darnell <bdarnell@beaker.local>
Sun, 7 Mar 2010 20:47:52 +0000 (12:47 -0800)
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.

tornado/web.py

index 55c6816af394adf67d503dcccb44e5a49ec1847c..ae7f7f0b37f020414234d34f79ffae5d0cce27df 100644 (file)
@@ -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.