tcalmant / jsonrpclib

A Python (2 & 3) JSON-RPC over HTTP that mirrors the syntax of xmlrpclib (aka jsonrpclib-pelix)
https://jsonrpclib-pelix.readthedocs.io/
Apache License 2.0
53 stars 24 forks source link

MultiCallIterator incorrectly raises StopIteration #43

Closed lonetech closed 4 years ago

lonetech commented 4 years ago

The __iter__ method in MultiCallIterator is a generator, using the yield statement to produce results. As such it should simply return in the end, not raise any exception. Just remove the raise StopIteration line to correct this bug.

In addition, the entire method is unnecessary, as iter() can derive it from __len__ and __getitem__. Outright removing __iter__ therefore also fixes the bug.

tcalmant commented 4 years ago

Hi, The __iter__ method doesn't raise StopIteration since version 0.4.0 (commit 3e2c52537d56db80b5eb6f2a05c4809e2692f3ac), are you using the latest release ?

lonetech commented 4 years ago

I remember checking the source repo, but must have gotten lost in another branch (maybe where it was cloned from). Sorry for the duplicate.

My starting point was stumbling upon the bug in the Ubuntu package version 0.3.1-1. Debian appears to still have that same version. So no, I wasn't using the latest version, a second mistake.

By the way, you don't need the return statement either (a function that reaches the end returns implicitly). Thanks for the PEP 479 link; I learned how this extra StopIteration could make it in to begin with.