Permalink
Browse files

In finish(), test if chunk is None rather than using truthiness to de…

…cide

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.
  • Loading branch information...
1 parent 8637a73 commit 45f76c518eaf032c40fd39cc1384577742e5dd4d Ben Darnell committed Mar 7, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 tornado/web.py
View
2 tornado/web.py
@@ -463,7 +463,7 @@ def flush(self, include_footers=False):
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.

0 comments on commit 45f76c5

Please sign in to comment.