]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
This is a fix to check the argument to RequestHandler.write() 979/head
authorMichael Atambo <mikeat4999@gmail.com>
Fri, 24 Jan 2014 11:04:00 +0000 (14:04 +0300)
committerMichael Atambo <mikeat4999@gmail.com>
Fri, 24 Jan 2014 11:05:31 +0000 (14:05 +0300)
is one of the accepted types: dict, bytes or unicode and raise a TypeError otherwise

tornado/web.py

index b22b11fe60888e9aa19a828f582dd1eb8a0eeaa9..d3f260bdbd1a929e35fb883eed61ce1d25be809c 100644 (file)
@@ -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")