From: Ben Darnell Date: Sun, 20 Oct 2013 19:26:27 +0000 (-0400) Subject: Return the correct type when yielding an empty dict. X-Git-Tag: v3.2.0b1~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95a25b197e825142a13cccef6ea7dcab49d7118c;p=thirdparty%2Ftornado.git Return the correct type when yielding an empty dict. --- diff --git a/tornado/gen.py b/tornado/gen.py index a363a4203..448576a78 100644 --- a/tornado/gen.py +++ b/tornado/gen.py @@ -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) diff --git a/tornado/test/gen_test.py b/tornado/test/gen_test.py index 3c51c23b4..726d131da 100644 --- a/tornado/test/gen_test.py +++ b/tornado/test/gen_test.py @@ -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)