Functions `rows_from_range` and `cols_from_range` fail on whole-column and whole-row ranges
In openpyxl.utils
the functions rows_from_range
and cols_from_range
rely on the function range_boundaries
, which returns a 4-tuple where each element may be either an integer or None
, however they don't check for the None
case. So, legal ranges like "D:F"
result in type errors.
>>> my_range = "D:F"
>>> openpyxl.utils.range_boundaries(my_range)
(4, None, 6, None)
>>> list(openpyxl.utils.rows_from_range(my_range))
---------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-24-d206692172a4> in <module>
----> 1 list(openpyxl.utils.rows_from_range(my_range))
~/me/projects/aaaa/.venv/lib/python3.9/site-packages/openpyxl/utils/cell.py in rows_from_range(range_string)
173 """
174 min_col, min_row, max_col, max_row = range_boundaries(range_string)
--> 175 rows = range(min_row, max_row + 1)
176 cols = [get_column_letter(col) for col in range(min_col, max_col + 1)]
177 for row in rows:
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
I expected this to instead yield ("D1", "E1", "F1), ("D2", "E2", "F2), ...
all the way to the maximum number of rows. Likewise, ranges like 5:10
should yield all the way to the maximum number of columns.
Also, the docstring of cols_from_range
says Yields one row at a time
when it should say Yields one column at a time
.