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

flex_layout - unsupported operand type(s) for -: 'str' and 'float' #1006

Closed
stuaxo opened this issue Dec 11, 2019 · 7 comments
Closed

flex_layout - unsupported operand type(s) for -: 'str' and 'float' #1006

stuaxo opened this issue Dec 11, 2019 · 7 comments
Labels
crash Problems preventing documents from being rendered

Comments

@stuaxo
Copy link

stuaxo commented Dec 11, 2019

Hi,
With weasyprint (version 50), I'm getting a casting error when trying to convert a page -

  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/flex.py", line 797, in flex_layout
    line.cross_size for line in flex_lines)
TypeError: unsupported operand type(s) for -: 'str' and 'float'

Unfortunately the page isn't public at the moment, so i can't share the page itself.

  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/app/app.py", line 78, in generate
    pdf = html.write_pdf()
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/__init__.py", line 211, in write_pdf
    font_config=font_config).write_pdf(
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/__init__.py", line 168, in render
    font_config)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/document.py", line 393, in _render
    [Page(page_box, enable_hinting) for page_box in page_boxes],
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/document.py", line 393, in <listcomp>
    [Page(page_box, enable_hinting) for page_box in page_boxes],
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/__init__.py", line 126, in layout_document
    pages = list(make_all_pages(context, root_box, html, pages))
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/pages.py", line 803, in make_all_pages
    page, resume_at = remake_page(i, context, root_box, html)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/pages.py", line 742, in remake_page
    page_number, page_state)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/pages.py", line 553, in make_page
    positioned_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 77, in block_level_layout_switch
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 130, in block_box_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 510, in block_container_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 77, in block_level_layout_switch
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 130, in block_box_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 510, in block_container_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 92, in block_level_layout_switch
    page_is_empty, absolute_boxes, fixed_boxes)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/flex.py", line 469, in flex_layout
    adjoining_margins=[]))
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 77, in block_level_layout_switch
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 130, in block_box_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 510, in block_container_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 77, in block_level_layout_switch
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 130, in block_box_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 510, in block_container_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 77, in block_level_layout_switch
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 130, in block_box_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 510, in block_container_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/blocks.py", line 92, in block_level_layout_switch
    page_is_empty, absolute_boxes, fixed_boxes)
  File "/usr/local/lib/python3.5/dist-packages/weasyprint/layout/flex.py", line 797, in flex_layout
    line.cross_size for line in flex_lines)
TypeError: unsupported operand type(s) for -: 'str' and 'float'
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
@liZe
Copy link
Member

liZe commented Dec 11, 2019

Hello,

Could you try the current master branch? An issue like this one has already been fixed since version 50 (#800).

@liZe liZe added the crash Problems preventing documents from being rendered label Dec 15, 2019
@stuaxo
Copy link
Author

stuaxo commented Dec 18, 2019

Unfortunately I can't test this, as I'm working in an environment where I can install packages from pypi, but not those that require git.

@liZe
Copy link
Member

liZe commented Dec 18, 2019

Unfortunately I can't test this, as I'm working in an environment where I can install packages from pypi, but not those that require git.

You can launch pip install https://github.com/Kozea/WeasyPrint/archive/master.zip 😉.

@stuaxo
Copy link
Author

stuaxo commented Dec 18, 2019

Thanks, they somehow haven't blocked this yet.

The bug does seem to be fixed.

@stuaxo
Copy link
Author

stuaxo commented Dec 18, 2019

EDIT: Sorry, I was looking at the wrong thing, the bug is still there.

@liZe
Copy link
Member

liZe commented Dec 18, 2019

EDIT: Sorry, I was looking at the wrong thing, the bug is still there.

😢

Could you please provide an HTML sample that triggers this issue?

@stuaxo
Copy link
Author

stuaxo commented Dec 18, 2019

This has made me find the issue though - inline SVGs (which I know don't work anyway).

I'll convert my SVGs to data urls (or de-inline them) and everything should be fixed.

Apologies for the noise !

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