In tableauserverclient/server/query.py, QuerySet.__iter__ catches a 400006 "invalid page number" error (which signals the end of pagination on some endpoints) and raises StopIteration to break out of the loop:
except ServerResponseError as e:
if e.code == "400006":
raise StopIteration # PEP 479: converted to RuntimeError inside generator
Since Python 3.7 (PEP 479), StopIteration raised inside a generator frame is automatically converted to RuntimeError. Because __iter__ is a generator (it uses yield from), this path raises RuntimeError instead of ending iteration cleanly.
We confirmed this locally — iterating a QuerySet against an endpoint that returns 400006 on page 2 raises:
RuntimeError: generator raised StopIteration
The fix is to return from the generator directly rather than raising StopIteration:
except ServerResponseError as e:
if e.code == "400006":
return # cleanly ends the generator
In
tableauserverclient/server/query.py,QuerySet.__iter__catches a 400006 "invalid page number" error (which signals the end of pagination on some endpoints) and raisesStopIterationto break out of the loop:Since Python 3.7 (PEP 479),
StopIterationraised inside a generator frame is automatically converted toRuntimeError. Because__iter__is a generator (it usesyield from), this path raisesRuntimeErrorinstead of ending iteration cleanly.We confirmed this locally — iterating a
QuerySetagainst an endpoint that returns 400006 on page 2 raises:The fix is to
returnfrom the generator directly rather than raisingStopIteration: