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

Prevent working with empty document #4019

Merged
merged 2 commits into from
Nov 15, 2024
Merged

Conversation

JorjMcKie
Copy link
Collaborator

Prevent page iterations if document has zero pages.

@JorjMcKie
Copy link
Collaborator Author

Addresses #4018.

Copy link
Collaborator

@julian-smith-artifex-com julian-smith-artifex-com left a comment

Choose a reason for hiding this comment

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

Not sure we should raise an exception in this case. Could we instead do:

if not self.page_count:
    return

So that for page in empty_document.pages(): ... doesn't raise?

@JorjMcKie
Copy link
Collaborator Author

Not sure we should raise an exception in this case. Could we instead do:

if not self.page_count:
    return

So that for page in empty_document.pages(): ... doesn't raise?

Sure, why not. It is a very improbable situation anyway: the code lives like this for 5 years or so, without ever this has been happening.

@julian-smith-artifex-com julian-smith-artifex-com merged commit 69ad0af into main Nov 15, 2024
2 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2024
@julian-smith-artifex-com julian-smith-artifex-com deleted the no-zero-page-work branch November 15, 2024 17:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants