UnboundLocalError upon empty row in an IterableWorkbook

Issue #401 resolved
created an issue

When encountering an empty row in an IterableWorkbook I get this exception:

  File "openpyxl/worksheet/iter_worksheet.py", line 106, in get_squared_range
    for row, cells in self._get_cells(min_row, min_col, max_row, max_col):
  File "openpyxl/worksheet/iter_worksheet.py", line 176, in _get_cells
    yield row, tuple(self._get_row(element, min_col, max_col))
  File "openpyxl/worksheet/iter_worksheet.py", line 163, in _get_row
    yield ReadOnlyCell(self, row, None, None)
UnboundLocalError: local variable 'row' referenced before assignment

This only happens since version 2.1.4. I haven't been able to create a small sample file but it should be easy to see what's wrong.

Comments (4)

  1. CharlieC

    Thanks for the report. It's a weird one but I did backport the code from 2.2 in a hurry.

    I suspect you're probably best off pinning to 2.1.3. A patch would have pass the row into _get_row() in case it's empty and a row of empty cells is expected.

  2. Log in to comment