Recursive call in Table Cell merging that causes a recursion error if the table is too big
There seems to be some recursion in the _grow_to method here that's used for table cell merging, that means that after a specific number of cells the code fails (for a single column table the max number of cells seems to be the recursion limit less 15). Is there a way around this that doesn't involve increasing the recursion limit?
Example code:
import sys import docx doc = docx.Document() table = doc.add_table(984, 1) table._cells[0].merge(table._cells[-1]) print('Merging 984 cells succeeds') try: doc = docx.Document() table = doc.add_table(985, 1) table._cells[0].merge(table._cells[-1]) except RecursionError: print('but merging 985 cells fails') sys.setrecursionlimit(1001) doc = docx.Document() table = doc.add_table(985, 1) table._cells[0].merge(table._cells[-1]) print('unless you increase the recursion limit')