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

Assertion Error in 54.0 #1538

Closed
janpeterka opened this issue Jan 12, 2022 · 3 comments
Closed

Assertion Error in 54.0 #1538

janpeterka opened this issue Jan 12, 2022 · 3 comments
Labels
crash Problems preventing documents from being rendered
Milestone

Comments

@janpeterka
Copy link

janpeterka commented Jan 12, 2022

I started getting AssertionError:

  File "/home/jan/.local/share/virtualenvs/kucharka-vjOexrDR/lib/python3.9/site-packages/weasyprint/layout/inline.py", line 1134, in text_align
    assert align == 'end'

Code was working in 53.4, not working now in 54.0

Downgrading to 53.4 solves the problem.

@grewn0uille
Copy link
Member

Hello!
Can you please share the related HTML/CSS?

@janpeterka
Copy link
Author

janpeterka commented Jan 12, 2022

Sure, but it happens on all render_pfd pages (using Flask-Weasyprint).

Controller:

    def pdf(self, id):
        from flask_weasyprint import render_pdf, HTML

        return render_pdf(HTML(string=self.template(template_name="show", print=True)))

Template:

{% extends "base/base.html.j2" %}
{% block title %} {{ recipe.name }} {% endblock %}

{% block content %}

<div id="recipe-info">
    <h2> {{ recipe.name }} </h2> 
</div>

<div class="row">
    <div class="col-md-10 col-sm-12">
        <table id="ingredients" class="table">
    <thead>
        <tr>
            <th>{{ texts.title }}</th>
            <th>Množství (na {{recipe.portion_count}} porcí)</th>
            <th></th>
        </tr>
    </thead>

    {% for ingredient in recipe.ingredients: %}
        {% set ingredient_amount = ingredient.amount * recipe.portion_count %}

        <tr>
            {% if not print and current_user.is_authenticated %}
                <td> {{ link_to(ingredient) }}
                    {% if ingredient.is_public %} {{ icon("public", class="text-secondary") }} {% endif %}
                </td>
            {% else %}
                <td> {{ ingredient.name }} </td>
            {% endif %}

            <td>
            {% if ingredient.is_measured %}
                {% if ingredient.measurement.thousand_fold and ingredient_amount % 1000 != ingredient_amount %}
                    {{ formatted_amount(ingredient_amount/1000) }} {{ ingredient.measurement.thousand_fold }}
                {% else %}
                    {{ formatted_amount(ingredient_amount) }} {{ ingredient.measurement.name }}
                {% endif %}

                {% if ingredient.alternative_measurement %}
                    {% set ns = namespace(title="přibližně\n") %}      
                    {% for conversion in ingredient.alternative_measurements %}
                        {% set ns.title = ns.title + formatted_amount(ingredient_amount/conversion.amount_from * conversion.amount_to) | string + " " + conversion.to_measurement.name %}

                        {% set ns.title = ns.title + "\n" %}
                    {% endfor %}
                    <abbr title="{{ ns.title }}">
                         {{ icon("info-circle", class="ms-1") }}
                    </abbr>   
                {% endif %}

            {% endif %}
            </td>

            <td><em>{{ ingredient.comment|default("", True) }}</em></td>
        </tr>
    {% endfor %}
</table>
    </div>
</div>


{% endblock %}

using Bootstrap for design

grewn0uille added a commit that referenced this issue Jan 12, 2022
Raise an InvalidValues error when text-align value is None.
@grewn0uille grewn0uille added this to the 54.1 milestone Jan 12, 2022
@grewn0uille grewn0uille added the crash Problems preventing documents from being rendered label Jan 12, 2022
@grewn0uille
Copy link
Member

Thanks for this bug report! It’s now fix in the 54.x branch.

This crash was caused by a variable that isn’t set in Bootstrap for text-align, which lead to a None value.

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