-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
TypeError: can only concatenate str (not "float") to str (after update from 61.2 to 62.1) #2154
Comments
Hi! Could you please share your HTML and CSS files, so that we can reproduce the bug? |
The HTML file is split into several django templates. It's nothing fancy Here's the css code (most of it is based on tailwindcss): Details
@page { html { body { page { .page-break-before { #header { #address { #date { .m-1 { .mx-2 { .mx-auto { .my-1 { .my-2 { .my-3 { .my-5 { .mb-2 { .mb-20 { .mb-3 { .mb-4 { .mb-5 { .mb-8 { .ml-1 { .ml-3 { .ml-4 { .ml-auto { .mr-2 { .mr-4 { .mr-5 { .mr-6 { .mr-7 { .mt-16 { .mt-1cm { .mt-2cm { .mt-3cm { .mt-4cm { .mt-2 { .mt-3 { .mt-4 { .mt-5 { .mt-6 { .mt-8 { .pl-12 { .pl-3 { .pl-6 { .pl-10 { .pl-2 { .px-2 { .ml-0 { .ml-1cm { .col-span-1 { .w-16 { .h-16 { .mr-4 { .grid { .grid-cols-1 { .block { .inline-block { .card { .card-body { .card-title { .flex { .flex-wrap { .items-center { .justify-between { .justify-center { .text-sm { .text-xs { .text-base { .text-lg { .text-xl { .text-2xl { .bg-primary { .bg-secondary { .max-w-full { .inline-flex { .no-underline { .text-black { .text-gray-500 { .content-item::after { .object-scale-down { .h-32 { .w-96 { .italic { .text-primary { .w-60 { .bg-accent { |
Simple sample to reproduce: <div style="display: grid">
<div style="margin: auto">
</div>
</div> |
Auto margins are not handled (there already was a TODO for this), but at least it doesn’t crash anymore. Fix #2154.
This bug should now be fixed, feedback is welcome! |
Thank you for your work. I just tried it with version |
After updating form 61.2 to 62.0/62.1 our code does not create the PDF anymore.
TypeError: can only concatenate str (not "float") to str
File "/Users/hintermayer/***.py", line 500, in _create_protocol
content = weasyprint.HTML(string=html_content, base_url=base_url).write_pdf(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/init.py", line 259, in write_pdf
self.render(font_config, counter_style, **options)
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/init.py", line 216, in render
return Document._render(self, font_config, counter_style, options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/document.py", line 262, in _render
[Page(page_box) for page_box in page_boxes],
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/init.py", line 130, in layout_document
pages = list(make_all_pages(context, root_box, html, pages))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/page.py", line 906, in make_all_pages
page, resume_at = remake_page(i, context, root_box, html)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/page.py", line 844, in remake_page
page, resume_at, next_page = make_page(
^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/page.py", line 646, in make_page
root_box, resume_at, next_page, _, _, _ = block_level_layout(
^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 59, in block_level_layout
return block_level_layout_switch(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 75, in block_level_layout_switch
return block_box_layout(
^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 124, in block_box_layout
result = block_container_layout(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 714, in block_container_layout
next_page, new_children, new_max_lines) = _in_flow_layout(
^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 506, in _in_flow_layout
collapsing_through, max_lines) = block_level_layout(
^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 59, in block_level_layout
return block_level_layout_switch(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 75, in block_level_layout_switch
return block_box_layout(
^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 124, in block_box_layout
result = block_container_layout(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 714, in block_container_layout
next_page, new_children, new_max_lines) = _in_flow_layout(
^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 506, in _in_flow_layout
collapsing_through, max_lines) = block_level_layout(
^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 59, in block_level_layout
return block_level_layout_switch(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 75, in block_level_layout_switch
return block_box_layout(
^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 124, in block_box_layout
result = block_container_layout(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 714, in block_container_layout
next_page, new_children, new_max_lines) = _in_flow_layout(
^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 506, in _in_flow_layout
collapsing_through, max_lines) = block_level_layout(
^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 59, in block_level_layout
return block_level_layout_switch(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 86, in block_level_layout_switch
result = grid_layout(
^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/grid.py", line 960, in grid_layout
rows_sizes = _resolve_tracks_sizes(
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/grid.py", line 392, in _resolve_tracks_sizes
child, _, _, _, _, _ = block_level_layout(
^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 59, in block_level_layout
return block_level_layout_switch(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/block.py", line 86, in block_level_layout_switch
result = grid_layout(
^^^^^^^^^^^^
File "/Users/hintermayer/Library/Caches/pypoetry/virtualenvs/platform-JeoL_1Z5-py3.12/lib/python3.12/site-packages/weasyprint/layout/grid.py", line 1112, in grid_layout
child.margin_left + child.border_left_width + child.padding_left +
TypeError: can only concatenate str (not "float") to str
The text was updated successfully, but these errors were encountered: