Fix filldown RuntimeError on header-only tables#698
Conversation
filldown eagerly reads the first data row to seed its fill values, so a table with a header but no data rows raised "RuntimeError: generator raised StopIteration" (the StopIteration from next() escaping the generator under PEP 479). fillright and fillleft already handle that input by returning the header unchanged; guard the seed read so filldown behaves the same.
64219c7 to
49511d9
Compare
PR Summary by QodoFix filldown StopIteration crash on header-only tables Description
Diagram
High-Level Assessment
Files changed (3)
|
|
Heads up that the red on the Python 3.8/3.9 jobs is |
filldownreads the first data row up front to seed its fill values, so a table that has a header but no data rows blows up withRuntimeError: generator raised StopIterationinstead of just passing the header through.fillrightandfillleftdon't have this problem — they return the header unchanged — so it's really an inconsistency between the three fill transforms.It's easy to hit, e.g. after a
selectthat filters everything out:Same PEP 479 class as the
iterrowslicefix in #613: theStopIterationfromnext()escapes the generator. I wrapped the seed read in the sametry/except StopIteration: returnthe function already uses for the header read just above it, so a header-only table now yields just the header like the other fill transforms.Added a regression test next to the existing
*_headerlessones and a changelog note. Verified withpytest --cov=petl petlandpytest --doctest-modules petl(all green) plus thesphinx-build -Wdocs build.