Crash with floats with percents in positions #263

Closed
humphrey opened this Issue Aug 7, 2015 · 7 comments

Comments

Projects
None yet
3 participants
@humphrey

humphrey commented Aug 7, 2015

From the command:

weasyprint http://getbootstrap.com/components/ ./bs.pdf

If I run pip freeze my enviroment is:

BeautifulSoup==3.2.1
beautifulsoup4==4.4.0
boto==2.38.0
cairocffi==0.7.2
CairoSVG==1.0.16
cffi==1.1.2
couchbase==2.0.3
cssselect==0.9.1
cssutils==1.0
Django==1.7.9
django-appconf==1.0.1
django-debug-toolbar==1.3.2
django-email-login==0.2.3
django-imagekit==2.0.4
django-impersonate==0.9.1
django-localflavor==1.1
django-pipeline==1.3.16
django-simple-history==1.6.3
django-social-auth==0.7.28
django-taggit==0.16.2
factory-boy==2.5.2
futures==3.0.3
html5lib==0.999999
httplib2==0.9.1
inlinestyler==0.2.1
lxml==3.4.4
oauth2==1.5.211
Pillow==2.9.0
psycopg2==2.6.1
pycparser==2.14
PyPDF2==1.25.1
Pyphen==0.9.1
python-memcached==1.57
python-openid==2.2.5
requests==2.7.0
simplejson==3.8.0
six==1.9.0
sqlparse==0.1.16
tinycss==0.3
tornado==2.4
WeasyPrint==0.24
wheel==0.24.0

And here is the exception:

Exception while render
Traceback (most recent call last):
  File "/Users/humphrey/Django/songlib/venv/bin/weasyprint", line 11, in <module>
    sys.exit(main())
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/__main__.py", line 156, in main
    getattr(html, 'write_' + format_)(output, **kwargs)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/__init__.py", line 164, in write_pdf
    return self.render(stylesheets).write_pdf(target, zoom, attachments)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/__init__.py", line 132, in render
    return Document._render(self, stylesheets, enable_hinting)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/document.py", line 322, in _render
    return cls([Page(p, enable_hinting) for p in page_boxes],
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/__init__.py", line 51, in layout_document
    pages = list(make_all_pages(context, root_box))
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/pages.py", line 553, in make_all_pages
    page_number)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/pages.py", line 505, in make_page
    positioned_boxes, positioned_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 60, in block_level_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 88, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 435, in block_container_layout
    adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 60, in block_level_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 88, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 435, in block_container_layout
    adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 60, in block_level_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 88, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 435, in block_container_layout
    adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 60, in block_level_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 88, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 435, in block_container_layout
    adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 60, in block_level_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 88, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 435, in block_container_layout
    adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 60, in block_level_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 88, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 435, in block_container_layout
    adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 60, in block_level_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 88, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 435, in block_container_layout
    adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 60, in block_level_layout
    absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 88, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/blocks.py", line 284, in block_container_layout
    context, child, box, absolute_boxes, fixed_boxes)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/float.py", line 37, in float_layout
    box, (containing_block.width, containing_block.height))
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/percentages.py", line 52, in resolve_position_percentages
    resolve_one_percentage(box, 'top', cb_height)
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/percentages.py", line 45, in resolve_one_percentage
    setattr(box, property_name, _percentage(value, refer_to))
  File "/Users/humphrey/Django/songlib/venv/lib/python2.7/site-packages/weasyprint/layout/percentages.py", line 31, in _percentage
    result = value.value * refer_to / 100.
TypeError: unsupported operand type(s) for /: 'unicode' and 'float'
@SimonSapin

This comment has been minimized.

Show comment
Hide comment
@SimonSapin

SimonSapin Aug 7, 2015

Member

It’d be helpful if you could minimize the test case, and copy/paste the HTML and CSS code here rather than refer to a website that might change.

Member

SimonSapin commented Aug 7, 2015

It’d be helpful if you could minimize the test case, and copy/paste the HTML and CSS code here rather than refer to a website that might change.

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Jan 9, 2016

Member

@humphrey do you have the bug with the latest version?

Member

liZe commented Jan 9, 2016

@humphrey do you have the bug with the latest version?

@humphrey

This comment has been minimized.

Show comment
Hide comment
@humphrey

humphrey Jan 14, 2016

Yeah, it appears so... But don't worry about it. It's not a document I ever need to convert :-)

Yeah, it appears so... But don't worry about it. It's not a document I ever need to convert :-)

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Jan 14, 2016

Member

Oh, it's a duplicate of #260, cool!

Member

liZe commented Jan 14, 2016

Oh, it's a duplicate of #260, cool!

@liZe liZe closed this Jan 14, 2016

@liZe liZe reopened this Jan 14, 2016

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Jan 14, 2016

Member

Or not…

Member

liZe commented Jan 14, 2016

Or not…

@liZe liZe added crash bug labels Jan 14, 2016

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe May 16, 2016

Member

For the record: still there in 0.28.

Member

liZe commented May 16, 2016

For the record: still there in 0.28.

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe May 16, 2016

Member

LOL. <div style="top:100%; float:left">

Member

liZe commented May 16, 2016

LOL. <div style="top:100%; float:left">

@liZe liZe closed this in 50ebc20 May 16, 2016

@liZe liZe changed the title from I got an exception while rendering ;-) to Crash with floats with percents in positions May 16, 2016

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Jan 15, 2017

kleink
Update py-weasyprint to 0.34.
Version 0.34
------------

Released on 2016-12-21.

Bug fixes:

* `#398 <Kozea/WeasyPrint#398>`_:
  Honor the presentational_hints option for PDFs.
* `#399 <Kozea/WeasyPrint#399>`_:
  Avoid CairoSVG-2.0.0rc* on Python 2.
* `#396 <Kozea/WeasyPrint#396>`_:
  Correctly close files open by mkstemp.
* `#403 <Kozea/WeasyPrint#403>`_:
  Cast the number of columns into int.
* Fix multi-page multi-columns and add related tests.


Version 0.33
------------

Released on 2016-11-28.

New features:

* `#393 <Kozea/WeasyPrint#393:
  Add tests on MacOS.
* `#370 <Kozea/WeasyPrint#370>`_:
  Enable @font-face on MacOS.

Bug fixes:

* `#389 <Kozea/WeasyPrint#389>`_:
  Always update resume_at when splitting lines.
* `#394 <Kozea/WeasyPrint#394>`_:
  Don't build universal wheels.
* `#388 <Kozea/WeasyPrint#388>`_:
  Fix logic when finishing block formatting context.


Version 0.32
------------

Released on 2016-11-17.

New features:

* `#28 <Kozea/WeasyPrint#28>`_:
  Support @font-face on Linux.
* Support CSS fonts level 3 almost entirely, including OpenType features.
* `#253 <Kozea/WeasyPrint#253>`_:
  Support presentational hints (optional).
* Support break-after, break-before and break-inside for pages and columns.
* `#384 <Kozea/WeasyPrint#384:
  Major performance boost.

Bux fixes:

* `#368 <Kozea/WeasyPrint#368>`_:
  Respect white-space for shrink-to-fit.
* `#382 <Kozea/WeasyPrint#382>`_:
  Fix the preferred width for column groups.
* Handle relative boxes in column-layout boxes.

Documentation:

* Add more and more documentation about Windows installation.
* `#355 <Kozea/WeasyPrint#355:
  Add fonts requirements for tests.


Version 0.31
------------

Released on 2016-08-28.

New features:

* `#124 <Kozea/WeasyPrint#124>`_:
  Add MIME sniffing for images.
* `#60 <Kozea/WeasyPrint#60>`_:
  CSS Multi-column Layout.
* `#197 <Kozea/WeasyPrint#197>`_:
  Add hyphens at line breaks activated by a soft hyphen.

Bux fixes:

* `#132 <Kozea/WeasyPrint#132>`_:
  Fix Python 3 compatibility on Windows.

Documentation:

* `#329 <Kozea/WeasyPrint#329>`_:
  Add documentation about installation on Windows.


Version 0.30
------------

Released on 2016-07-18.

WeasyPrint now depends on html5lib-0.999999999.

Bux fixes:

* Fix Acid2
* `#325 <Kozea/WeasyPrint#325>`_:
  Cutting lines is broken in page margin boxes.
* `#334 <Kozea/WeasyPrint#334>`_:
  Newest html5lib 0.999999999 breaks rendering.


Version 0.29
------------

Released on 2016-06-17.

Bug fixes:

* `#263 <Kozea/WeasyPrint#263:
  Don't crash with floats with percents in positions.
* `#323 <Kozea/WeasyPrint#323>`_:
  Fix CairoSVG 2.0 pre-release dependency in Python 2.x.


Version 0.28
------------

Released on 2016-05-16.

Bug fixes:

* `#189 <Kozea/WeasyPrint#189>`_:
  ``white-space: nowrap`` still wraps on hyphens
* `#305 <Kozea/WeasyPrint#305>`_:
  Fix crashes on some tables
* Don't crash when transform matrix isn't invertible
* Don't crash when rendering ratio-only SVG images
* Fix margins and borders on some tables


Version 0.27
------------

Released on 2016-04-08.

New features:

* `#295 <Kozea/WeasyPrint#295>`_:
  Support the 'rem' unit.
* `#299 <Kozea/WeasyPrint#299>`_:
  Enhance the support of SVG images.

Bug fixes:

* `#307 <Kozea/WeasyPrint#307>`_:
  Fix the layout of cells larger than their tables.

Documentation:

* The website is now on GitHub Pages, the documentation is on Read the Docs.
* `#297 <Kozea/WeasyPrint#297>`_:
  Rewrite the CSS chapter of the documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment