Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cbm755 opened this issue May 15, 2024 · 5 comments
Closed

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

cbm755 opened this issue May 15, 2024 · 5 comments
Labels
fix developed release schedule to be determined

Comments

@cbm755
Copy link
Contributor

cbm755 commented May 15, 2024

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

@cbm755 cbm755 changed the title regression: fill_textbox: IndexError: pop from empty list using regression: fill_textbox: IndexError: pop from empty list May 15, 2024
@cbm755
Copy link
Contributor Author

cbm755 commented May 15, 2024

The box details don't matter too much. Here's an updated version that shows the file is actually written, and contains the text. Not sure if this is harmful or just cosmetic.

import fitz

print(fitz.version)

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

r = fitz.Rect(10, 10, 300, 300)
tw = fitz.TextWriter(page.rect)

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

excess = tw.fill_textbox(r, "blah blah blah blah")
print(excess)

tw.write_text(page, color=(0, 0, 0))

print("\nhello, we got here")

doc.save("foo.pdf")

@cbm755
Copy link
Contributor Author

cbm755 commented May 19, 2024

Still true in 1.24.4

@julian-smith-artifex-com
Copy link
Collaborator

Thanks for this, i've reproduced it. Investigating some more now.

@julian-smith-artifex-com
Copy link
Collaborator

It turns out that this is a change of a diagnostic, not a change in behaviour.

I've disabled the diagnostic in my tree so it'll won't appear in a future release.

@julian-smith-artifex-com
Copy link
Collaborator

Fixed in 1.24.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix developed release schedule to be determined
Projects
None yet
Development

No branches or pull requests

2 participants