Open troygraben opened 3 years ago
Cc @srinivasgowda and @goperry
This is actually the cause of issue #86 (which has been closed for some reason).
The issue arise because of PEP 0479. Since python 3.7 raising a StopIteration
exception explicitely inside a generator is deprecated and now raises a RuntimeException
.
I think a much simpler fix for this could be to turn the raise StopIteration
into a return
. In its current state, this PR would disallow concurrent iterations of the TokenTable
. (Moreover, calling __next__
on a iterator that already eached the end would call still token_table_get_next
, which seems pretty surprising.)
@Celelibi Your approach sounds much more sensible to me. It seems that many docs online still reference using StopIteration even though this PEP 0479 is has been in place for many years.
Cc @dell-client-linux
This change fixes the problem for me as well. Please merge :)
Hi, still experiencing this issue.
The
__iter__
function must perform initialization and return the iterator object itself. The__next__
function must return the next item or raise StopIteration when no more elements are available.This fixes the StopIteration exception being uncaught by the for loop when the iterator reaches the end of the collection. This could be encountered when calling
smbios-token-ctl --dump-tokens
.