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

fix: initialize next_box_height to avoid unboundlocalerrors #2107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

filipweidemann
Copy link

As promised in #2106, this is my proposed fix for UnboundLocalErrors inside of the layout/column.py module.

I am still not sure yet if initializing the value with 0 is the right move here, however, in our case, monkey-patching it this way seemed to work without any further problems.

Let me know if this is fine.

@@ -176,6 +176,9 @@ def columns_layout(context, box, bottom_space, skip_stack, containing_block,
new_boxes.append(new_box)
column_skip_stack = resume_at

# Avoid edge cases resulting in a UnboundLocalError in line 223
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't add a comment here. To me it is obvious that there are multiple conditions where next_box_height is not set.

@FelixSchwarz
Copy link
Contributor

I basically know next to nothing about the WeasyPrint code but the change looks good to me.

@liZe
Copy link
Member

liZe commented Apr 30, 2024

I basically know next to nothing about the WeasyPrint code but the change looks good to me.

It looks good to me too, but I’d like to have a way to reproduce the problem before merging, so that we can add a test. See #2106.

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.

None yet

3 participants