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 with floats with percents in positions #263

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

Crash with floats with percents in positions #263

humphrey opened this issue Aug 7, 2015 · 7 comments
Labels
bug Existing features not working as expected crash Problems preventing documents from being rendered

Comments

@humphrey
Copy link

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
Copy link
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.

@liZe
Copy link
Member

liZe commented Jan 9, 2016

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

@humphrey
Copy link
Author

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

@liZe
Copy link
Member

liZe commented Jan 14, 2016

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

@liZe liZe closed this as completed Jan 14, 2016
@liZe liZe reopened this Jan 14, 2016
@liZe
Copy link
Member

liZe commented Jan 14, 2016

Or not…

@liZe liZe added crash Problems preventing documents from being rendered bug Existing features not working as expected labels Jan 14, 2016
@liZe
Copy link
Member

liZe commented May 16, 2016

For the record: still there in 0.28.

@liZe
Copy link
Member

liZe commented May 16, 2016

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

@liZe liZe closed this as completed in 50ebc20 May 16, 2016
@liZe liZe changed the title I got an exception while rendering ;-) Crash with floats with percents in positions May 16, 2016
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Jan 15, 2017
Version 0.34
------------

Released on 2016-12-21.

Bug fixes:

* `#398 <https://github.com/Kozea/WeasyPrint/issues/398>`_:
  Honor the presentational_hints option for PDFs.
* `#399 <https://github.com/Kozea/WeasyPrint/pull/399>`_:
  Avoid CairoSVG-2.0.0rc* on Python 2.
* `#396 <https://github.com/Kozea/WeasyPrint/issues/396>`_:
  Correctly close files open by mkstemp.
* `#403 <https://github.com/Kozea/WeasyPrint/issues/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 <https://github.com/Kozea/WeasyPrint/issues/393>`_:
  Add tests on MacOS.
* `#370 <https://github.com/Kozea/WeasyPrint/issues/370>`_:
  Enable @font-face on MacOS.

Bug fixes:

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


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

Released on 2016-11-17.

New features:

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

Bux fixes:

* `#368 <https://github.com/Kozea/WeasyPrint/issues/368>`_:
  Respect white-space for shrink-to-fit.
* `#382 <https://github.com/Kozea/WeasyPrint/issues/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 <https://github.com/Kozea/WeasyPrint/issues/355>`_:
  Add fonts requirements for tests.


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

Released on 2016-08-28.

New features:

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

Bux fixes:

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

Documentation:

* `#329 <https://github.com/Kozea/WeasyPrint/issues/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 <https://github.com/Kozea/WeasyPrint/issues/325>`_:
  Cutting lines is broken in page margin boxes.
* `#334 <https://github.com/Kozea/WeasyPrint/issues/334>`_:
  Newest html5lib 0.999999999 breaks rendering.


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

Released on 2016-06-17.

Bug fixes:

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


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

Released on 2016-05-16.

Bug fixes:

* `#189 <https://github.com/Kozea/WeasyPrint/issues/189>`_:
  ``white-space: nowrap`` still wraps on hyphens
* `#305 <https://github.com/Kozea/WeasyPrint/issues/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 <https://github.com/Kozea/WeasyPrint/pull/295>`_:
  Support the 'rem' unit.
* `#299 <https://github.com/Kozea/WeasyPrint/pull/299>`_:
  Enhance the support of SVG images.

Bug fixes:

* `#307 <https://github.com/Kozea/WeasyPrint/issues/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 <https://github.com/Kozea/WeasyPrint/issues/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
Labels
bug Existing features not working as expected crash Problems preventing documents from being rendered
Projects
None yet
Development

No branches or pull requests

3 participants