- for (int i=0; i < PyList_Size(additional); ++i)
- {
- PyObject *it = PyList_GET_ITEM(additional, i);
- if (!PyTuple_Check(it))
- eFatal("poll item is not a tuple");
- if (PyTuple_Size(it) != 2)
- eFatal("poll tuple size is not 2");
- int fd = PyObject_AsFileDescriptor(PyTuple_GET_ITEM(it, 0));
- if (fd == -1)
- eFatal("poll tuple not a filedescriptor");
- pfd[nativecount + i].fd = fd;
- pfd[nativecount + i].events = PyInt_AsLong(PyTuple_GET_ITEM(it, 1));
+ PyObject *key, *val;
+ int pos=0;
+ while (PyDict_Next(additional, &pos, &key, &val)) {
+ pfd[i].fd = PyObject_AsFileDescriptor(key);
+ pfd[i++].events = PyInt_AsLong(val);