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

TypeError: string indices must be integers #1378

Closed
vwasteels opened this issue Jun 9, 2021 · 2 comments
Closed

TypeError: string indices must be integers #1378

vwasteels opened this issue Jun 9, 2021 · 2 comments
Labels
crash Problems preventing documents from being rendered
Milestone

Comments

@vwasteels
Copy link

Sorry I'm struggling with installation ...

My HTML handles SVGs like so :

<svg>
<use x-link:href="#some-id-refering-to-a-symbol">
</svg>

this is my HTML file
test.txt

and here is the error I get :

ERROR: Failed to load inline SVG: unbound prefix: line 1, column 0
ERROR: Failed to load inline SVG: unbound prefix: line 1, column 0
Traceback (most recent call last):
  File "/usr/local/bin/weasyprint", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/weasyprint/__main__.py", line 214, in main
    html.write_pdf(output, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/weasyprint/__init__.py", line 180, in write_pdf
    self.render(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/__init__.py", line 134, in render
    return Document._render(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/document.py", line 855, in _render
    [Page(page_box) for page_box in page_boxes],
  File "/usr/local/lib/python3.9/site-packages/weasyprint/document.py", line 855, in <listcomp>
    [Page(page_box) for page_box in page_boxes],
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/__init__.py", line 124, in layout_document
    pages = list(make_all_pages(context, root_box, html, pages))
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/pages.py", line 802, in make_all_pages
    page, resume_at = remake_page(i, context, root_box, html)
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/pages.py", line 739, in remake_page
    page, resume_at, next_page = make_page(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/pages.py", line 549, in make_page
    root_box, resume_at, next_page, _, _ = block_level_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 58, in block_level_layout
    return block_level_layout_switch(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 72, in block_level_layout_switch
    return block_box_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 126, in block_box_layout
    block_container_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 517, in block_container_layout
    collapsing_through) = block_level_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 58, in block_level_layout
    return block_level_layout_switch(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 72, in block_level_layout_switch
    return block_box_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 126, in block_box_layout
    block_container_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 517, in block_container_layout
    collapsing_through) = block_level_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 58, in block_level_layout
    return block_level_layout_switch(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 72, in block_level_layout_switch
    return block_box_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 126, in block_box_layout
    block_container_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 517, in block_container_layout
    collapsing_through) = block_level_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 58, in block_level_layout
    return block_level_layout_switch(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 72, in block_level_layout_switch
    return block_box_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 126, in block_box_layout
    block_container_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 517, in block_container_layout
    collapsing_through) = block_level_layout(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 58, in block_level_layout
    return block_level_layout_switch(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/blocks.py", line 88, in block_level_layout_switch
    return flex_layout(
  File "/usr/local/lib/python3.9/site-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.9/site-packages/weasyprint/layout/preferred.py", line 48, in min_content_width
    return block_min_content_width(context, box, outer)
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/preferred.py", line 168, in block_min_content_width
    return _block_content_width(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/preferred.py", line 97, in _block_content_width
    children_widths = [
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/preferred.py", line 98, in <listcomp>
    function(context, child, outer=True) for child in box.children
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/preferred.py", line 48, in min_content_width
    return block_min_content_width(context, box, outer)
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/preferred.py", line 168, in block_min_content_width
    return _block_content_width(
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/preferred.py", line 105, in _block_content_width
    return adjust(box, outer, width)
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/preferred.py", line 161, in adjust
    return margin_width(box, fixed, left, right)
  File "/usr/local/lib/python3.9/site-packages/weasyprint/layout/preferred.py", line 140, in margin_width
    width += box.style['border_left_width']
  File "/usr/local/lib/python3.9/site-packages/weasyprint/css/__init__.py", line 718, in __missing__
    value = function(self, key, value)
  File "/usr/local/lib/python3.9/site-packages/weasyprint/css/computed_values.py", line 401, in border_width
    return length(style, name, value, pixels_only=True)
  File "/usr/local/lib/python3.9/site-packages/weasyprint/css/computed_values.py", line 325, in length
    font_size = style['font_size']
TypeError: string indices must be integers
@vwasteels
Copy link
Author

sorry for .txt file , but it looks like GH refuses me to send .html ...

@liZe liZe closed this as completed in 23dbd70 Jun 13, 2021
@liZe
Copy link
Member

liZe commented Jun 13, 2021

Thanks a lot for the bug report! It’s now fixed. Until the next release, you can avoid the em unit in border widths, that’s why this crash was happening.

@liZe liZe added the crash Problems preventing documents from being rendered label Jun 13, 2021
@liZe liZe added this to the 53.0 milestone Jun 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Problems preventing documents from being rendered
Projects
None yet
Development

No branches or pull requests

2 participants