Skip to content

regression: fill_textbox: IndexError: pop from empty list #3479

@cbm755

Description

@cbm755

Description of the bug

On 1.24.3 (but not on 1.24.2) fill_textbox generates some kind of exceptions that print to the screen but do not raise in Python.

How to reproduce the bug

Here's a MWE:

import fitz

print(fitz.version)

doc = fitz.open()
page = doc.new_page()

r = fitz.Rect(-15.0, 43.0, 115.0, 67.0)
tw = fitz.TextWriter(page.rect)

print("\nabout to fill the textbox\n")

excess = tw.fill_textbox(r, "test", fontsize=8, align=fitz.TEXT_ALIGN_CENTER)

print("\nhello, we got here")

On my Fedora 39 system, this gives:

('1.24.3', '1.24.2', '20240509000001')

about to fill the textbox

../../../.local/lib/python3.12/site-packages/pymupdf/__init__.py:87:exception_info: exception_info:
Traceback (most recent call last):
  File "/home/cbm/.local/lib/python3.12/site-packages/pymupdf/utils.py", line 4686, in fill_textbox
    line, tl = new_lines.pop(0)
               ^^^^^^^^^^^^^^^^
IndexError: pop from empty list

hello, we got here

I've also seen this on Ubuntu 22.04.

PyMuPDF version

1.24.3

Operating system

Linux

Python version

3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix developedrelease schedule to be determined

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions