Text breaking exception on version 52.4
See original GitHub issueI’m using Weasyprint to convert a HTML page to PNG, which works really nicely, thanks for the great tool!
In a rare case weasyprint consistently crashes on a page, while doing text-breaking on a text block. Below is the exception I get when this happens. The text it crashes on is a Dutch sentence that includes a phone number, no special characters at all. Considering my page size I would expect it to wrap to 2 lines.
If it helps I can share the HTML content and/or line of text in private.
- Weasyprint 52.4
- Ubuntu 20.04.2 LTS
- Started using the command line, with stdin and stdout:
weasyprint --encoding utf8 --format png --resolution 203 - -
- On the stdin I feed it the HTML page, on the stdout I usually receive the PNG
Exception:
File "/usr/local/bin/weasyprint", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/dist-packages/weasyprint/__main__.py", line 214, in main
getattr(html, 'write_' + format_)(output, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/weasyprint/__init__.py", line 320, in write_png
self.render(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/__init__.py", line 172, in render
return Document._render(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/document.py", line 406, in _render
[Page(page_box, enable_hinting) for page_box in page_boxes],
File "/usr/local/lib/python3.8/dist-packages/weasyprint/document.py", line 406, in <listcomp>
[Page(page_box, enable_hinting) for page_box in page_boxes],
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/__init__.py", line 123, in layout_document
pages = list(make_all_pages(context, root_box, html, pages))
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/pages.py", line 801, in make_all_pages
page, resume_at = remake_page(i, context, root_box, html)
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/pages.py", line 738, in remake_page
page, resume_at, next_page = make_page(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/pages.py", line 548, in make_page
root_box, resume_at, next_page, _, _ = block_level_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 58, in block_level_layout
return block_level_layout_switch(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 72, in block_level_layout_switch
return block_box_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 126, in block_box_layout
block_container_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 517, in block_container_layout
collapsing_through) = block_level_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 58, in block_level_layout
return block_level_layout_switch(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 72, in block_level_layout_switch
return block_box_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 126, in block_box_layout
block_container_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 517, in block_container_layout
collapsing_through) = block_level_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 58, in block_level_layout
return block_level_layout_switch(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 72, in block_level_layout_switch
return block_box_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 126, in block_box_layout
block_container_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 517, in block_container_layout
collapsing_through) = block_level_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 58, in block_level_layout
return block_level_layout_switch(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/blocks.py", line 88, in block_level_layout_switch
return flex_layout(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/flex.py", line 141, in flex_layout
content_size = min_content_width(context, new_child, outer=False)
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/preferred.py", line 48, in min_content_width
return block_min_content_width(context, box, outer)
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/preferred.py", line 169, in block_min_content_width
return _block_content_width(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/preferred.py", line 98, in _block_content_width
children_widths = [
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/preferred.py", line 99, in <listcomp>
function(context, child, outer=True) for child in box.children
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/preferred.py", line 52, in min_content_width
return inline_min_content_width(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/preferred.py", line 194, in inline_min_content_width
widths = list(widths)
File "/usr/local/lib/python3.8/dist-packages/weasyprint/layout/preferred.py", line 298, in inline_line_widths
text.split_first_line(
File "/usr/local/lib/python3.8/dist-packages/weasyprint/text.py", line 1050, in split_first_line
can_break_text(first_line_text.strip(), style['lang']))
File "/usr/local/lib/python3.8/dist-packages/weasyprint/text.py", line 1312, in can_break_text
return any(attr.is_line_break for attr in log_attrs[1:length - 1])
IndexError: index too large (expected 12 <= 11)
If you need any more information, let me know.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Universal Resource Scheduling version history - Microsoft Learn
3.12.52.4. (Includes Resource Scheduling controls version 1.1.7.211681). Fixed an issue where a new booking is created from the booking form ...
Read more >c# - Exception in catch block means the finally block never ...
Visual Studio usually breaks on an Exception and then you can continue the app, you just press the little play button again.
Read more >Changelog — WeasyPrint 57.1 documentation - CourtBouillon
Version 52.5 . Released on 2021-04-17. Bug fixes: #1336: Fix text breaking exception. #1318: Fix @font-face rules with Pango 1.48.3+.
Read more >PART 52—LICENSES, CERTIFICATIONS, AND APPROVALS ...
(b)(1) An applicant or licensee who references a design certification rule may request an exemption from one or more elements of the certification...
Read more >Learning the Basics - Gradle User Manual
Username and password should never be checked in plain text into version control as ... Software projects often break up software components into...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks a lot for the report.
It’s fixed, tests are welcome!
Thanks, we’ll investigate!