Browse Source

event: Change result of AsyncFuture gather() to return list

Better matches asyncio gather

See #1738
rdb 4 months ago
parent
commit
e57c71d8e4
2 changed files with 3 additions and 3 deletions
  1. 2 2
      panda/src/event/asyncFuture_ext.cxx
  2. 1 1
      tests/event/test_futures.py

+ 2 - 2
panda/src/event/asyncFuture_ext.cxx

@@ -63,13 +63,13 @@ static PyObject *get_done_result(const AsyncFuture *future) {
       // If it's an AsyncGatheringFuture, get the result for each future.
       const AsyncGatheringFuture *gather = (const AsyncGatheringFuture *)future;
       Py_ssize_t num_futures = (Py_ssize_t)gather->get_num_futures();
-      PyObject *results = PyTuple_New(num_futures);
+      PyObject *results = PyList_New(num_futures);
 
       for (Py_ssize_t i = 0; i < num_futures; ++i) {
         PyObject *result = get_done_result(gather->get_future((size_t)i));
         if (result != nullptr) {
           // This steals a reference.
-          PyTuple_SET_ITEM(results, i, result);
+          PyList_SET_ITEM(results, i, result);
         } else {
           Py_DECREF(results);
           return nullptr;

+ 1 - 1
tests/event/test_futures.py

@@ -527,7 +527,7 @@ def test_future_gather():
     assert gather.done()
 
     assert not gather.cancelled()
-    assert check_result(gather, (1, 2))
+    assert check_result(gather, [1, 2])
 
 
 def test_future_gather_cancel_inner():