question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'BlockBox' object has no attribute 'index'

See original GitHub issue

First, thanks for WeasyPrint, it’s really great!

I encountered a crash with:

python -m weasyprint "https://fr.wikipedia.org/wiki/Python_(langage)" --stylesheet https://vpoulailleau.github.io/formation/css/main.css python.pdf

Python is Python 3.8.4, WeasyPrint is WeasyPrint 51.

Here is the traceback:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/__main__.py", line 216, in <module>
    main()
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/__main__.py", line 212, in main
    getattr(html, 'write_' + format_)(output, **kwargs)
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/__init__.py", line 208, in write_pdf
    return self.render(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/__init__.py", line 166, in render
    return Document._render(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/document.py", line 393, in _render
    [Page(page_box, enable_hinting) for page_box in page_boxes],
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/document.py", line 393, in <listcomp>
    [Page(page_box, enable_hinting) for page_box in page_boxes],
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/__init__.py", line 126, in layout_document
    pages = list(make_all_pages(context, root_box, html, pages))
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/pages.py", line 804, in make_all_pages
    page, resume_at = remake_page(i, context, root_box, html)
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/pages.py", line 741, in remake_page
    page, resume_at, next_page = make_page(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/pages.py", line 551, in make_page
    root_box, resume_at, next_page, _, _ = block_level_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 61, in block_level_layout
    return block_level_layout_switch(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 75, in block_level_layout_switch
    return block_box_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 128, in block_box_layout
    block_container_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 504, in block_container_layout
    collapsing_through) = block_level_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 61, in block_level_layout
    return block_level_layout_switch(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 75, in block_level_layout_switch
    return block_box_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 128, in block_box_layout
    block_container_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 504, in block_container_layout
    collapsing_through) = block_level_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 61, in block_level_layout
    return block_level_layout_switch(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 75, in block_level_layout_switch
    return block_box_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 128, in block_box_layout
    block_container_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 504, in block_container_layout
    collapsing_through) = block_level_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 61, in block_level_layout
    return block_level_layout_switch(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 75, in block_level_layout_switch
    return block_box_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 128, in block_box_layout
    block_container_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 504, in block_container_layout
    collapsing_through) = block_level_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 61, in block_level_layout
    return block_level_layout_switch(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 75, in block_level_layout_switch
    return block_box_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 128, in block_box_layout
    block_container_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 504, in block_container_layout
    collapsing_through) = block_level_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 61, in block_level_layout
    return block_level_layout_switch(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 75, in block_level_layout_switch
    return block_box_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 128, in block_box_layout
    block_container_layout(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 348, in block_container_layout
    result = find_earlier_page_break(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 817, in find_earlier_page_break
    result = find_earlier_page_break(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 817, in find_earlier_page_break
    result = find_earlier_page_break(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 817, in find_earlier_page_break
    result = find_earlier_page_break(
  File "/home/vincent/venv_deleteme/lib/python3.8/site-packages/weasyprint/layout/blocks.py", line 824, in find_earlier_page_break
    resume_at = (new_child.index, resume_at)
AttributeError: 'BlockBox' object has no attribute 'index'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Tontynacommented, Jul 28, 2020

Finally succeeded in creating a minimal snippet to trigger the crash:

<style>
.neverbreak {
  column-width: 17cm; 
  break-after:avoid;
}
@page {
  size: 21cm 10cm;
  margin: 2cm;
}
</style>
<div class="neverbreak">
  <p>Here column-width doesn't generate columns, but 
  suppresses break-inside.</p>
  <p>In combination with break-after:avoid
  the following floating and page-crossing div crashes WeasyPrint.
  </p>
</div> 

<div style="float:right">
  <p>line1</p>
  <p>line2</p>
  <p>line3</p>
  <p>too many</p>
  <p>lines</p>
</div>

On the Wikipedia page the neverbreak is triggered by the “Notes et références” list (column-width) followed by a break-avoiding heading.

Crash happens, when the subsequent “Sur les autres projets Wikimedia” (boite-a-droite) coincidentally meets the end of a page.

0reactions
liZecommented, Dec 22, 2020

That’s actually the same bug as #1191.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - object has no attribute 'index'
The only solution I found is subclassing data frame : import() pandas as pd from pandasql import sqldf class ABC(pd.
Read more >
2018-October.txt - Mailing Lists - OpenStack
For those of you that have never heard of the CCA, I'll briefly explain > what they ... connection event: AttributeError: 'NoneType' object...
Read more >
AttributeError : 'module' object has no attribute 'index'-django
Coding example for the question AttributeError : 'module' object has no attribute 'index'-django.
Read more >
Update git submodules · bd325ad333 - openstack - OpenDev
When doing a non incremental Ceph to Ceph backup, instead of doing a full backup that ... error message: AttributeError: 'RBDDriver' object has...
Read more >
Untitled
The key is used as * the attribute name and the value is the function that gets called for every * single node...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found