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

Crash: ZeroDivisionError with dashed lines #49

Closed
Smylers opened this issue Mar 15, 2013 · 1 comment
Closed

Crash: ZeroDivisionError with dashed lines #49

Smylers opened this issue Mar 15, 2013 · 1 comment

Comments

@Smylers
Copy link
Contributor

Smylers commented Mar 15, 2013

This HTML file crashes WeasyPrint (0.17) with a division-by-zero error: http://www.stripey.com/demo/weasyprint/dash.html

It works as intended if the border style is changed from dashed to dotted.

I can only get the crash to occur when the bordered element breaks across pages and contains a floated element, so possibly this is related to Issue #36.

Here's the stack trace:

Traceback (most recent call last):
  File "/usr/local/bin/weasyprint", line 9, in <module>
    load_entry_point('WeasyPrint==0.17', 'console_scripts', 'weasyprint')()
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/__main__.py", line 141, in main
    getattr(html, 'write_' + format_)(output, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/__init__.py", line 159, in write_pdf
    return self.render(stylesheets).write_pdf(target, zoom)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/document.py", line 393, in write_pdf
    page.paint(context, scale=scale)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/document.py", line 226, in paint
    draw_page(self._page_box, cairo_context, self._enable_hinting)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/draw.py", line 61, in draw_page
    draw_stacking_context(context, stacking_context, enable_hinting)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/draw.py", line 167, in draw_stacking_context
    draw_stacking_context(context, child_context, enable_hinting)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/draw.py", line 137, in draw_stacking_context
    context, stacking_context.page, block, enable_hinting)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/draw.py", line 67, in draw_box_background_and_border
    draw_border(context, box, enable_hinting)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/draw.py", line 334, in draw_border
    side, border_edge, padding_edge)
  File "/usr/local/lib/python2.7/dist-packages/weasyprint/draw.py", line 477, in draw_border_segment
    dash = length / (2 * round(length / (2 * dash)))
ZeroDivisionError: float division by zero
@SimonSapin
Copy link
Member

Fixed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants