]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Return the correct type when yielding an empty dict.
authorBen Darnell <ben@bendarnell.com>
Sun, 20 Oct 2013 19:26:27 +0000 (15:26 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 20 Oct 2013 19:26:27 +0000 (15:26 -0400)
tornado/gen.py
tornado/test/gen_test.py

index a363a420364d12bd1e827f14166ac869954b79fd..448576a787f0e7d819938475afef3b1193b7bfdf 100644 (file)
@@ -432,7 +432,7 @@ class Multi(YieldPoint):
 
     def get_result(self):
         result = (i.get_result() for i in self.children)
-        if self.keys:
+        if self.keys is not None:
             return dict(zip(self.keys, result))
         else:
             return list(result)
index 3c51c23b49b75544ef4b8c9742ef43969de541f5..726d131da7f46bde1f84f6493d145011d6871606 100644 (file)
@@ -326,6 +326,14 @@ class GenEngineTest(AsyncTestCase):
         end = time.time()
         self.assertLess(end - start, 1.0)
 
+    @gen_test
+    def test_multi_empty(self):
+        # Empty lists or dicts should return the same type.
+        x = yield []
+        self.assertTrue(isinstance(x, list))
+        y = yield {}
+        self.assertTrue(isinstance(y, dict))
+
     @gen_test
     def test_future(self):
         result = yield self.async_future(1)