From: Michael Atambo Date: Fri, 24 Jan 2014 11:04:00 +0000 (+0300) Subject: This is a fix to check the argument to RequestHandler.write() X-Git-Tag: v4.0.0b1~136^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e442a6dcdc52002481fa421a9c7768eada75dc03;p=thirdparty%2Ftornado.git This is a fix to check the argument to RequestHandler.write() is one of the accepted types: dict, bytes or unicode and raise a TypeError otherwise --- diff --git a/tornado/web.py b/tornado/web.py index b22b11fe6..d3f260bdb 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -604,6 +604,8 @@ class RequestHandler(object): raise RuntimeError("Cannot write() after finish(). May be caused " "by using async operations without the " "@asynchronous decorator.") + if not isinstance(chunk, (bytes_type, unicode_type, dict)): + raise TypeError("write() only accepts bytes, unicode, and dict objects") if isinstance(chunk, dict): chunk = escape.json_encode(chunk) self.set_header("Content-Type", "application/json; charset=UTF-8")