Skip to content

fix: skip widgets with empty or infinite rects in remove_rotation#4953

Open
thakoreh wants to merge 1 commit intopymupdf:mainfrom
thakoreh:fix/remove-rotation-empty-widget
Open

fix: skip widgets with empty or infinite rects in remove_rotation#4953
thakoreh wants to merge 1 commit intopymupdf:mainfrom
thakoreh:fix/remove-rotation-empty-widget

Conversation

@thakoreh
Copy link
Copy Markdown

Fixes #4950

remove_rotation() iterates over all widgets and calls widget.update()
after transforming their rect. Widgets with empty or infinite rects
(like invisible signature fields with Rect(0, 0, 0, 0)) cause
ValueError('bad rect') during the internal validation in update().

This skips widgets with empty or infinite rects before the update
call, and wraps widget.update() in a try/except for any remaining
edge cases.

remove_rotation() calls widget.update() on every widget, but widgets
with empty or infinite rects (like invisible signature fields) cause
ValueError('bad rect') during validation.

Skip these widgets and also guard widget.update() with a try/except
for any remaining edge cases.

Fixes pymupdf#4950
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@thakoreh
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Comment thread src/__init__.py
Comment on lines +11919 to +11922
try:
widget.update()
except ValueError:
pass
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need this exception handling, now that we ignore empty or infinite rectangle r? I.e. what is meant by remaining edge cases?

github-actions bot added a commit that referenced this pull request Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

remove_rotation() raises ValueError on widgets with empty/infinite rects

2 participants