Skip to content

Assertion Error in 54.0 #1538

Closed
Closed
@janpeterka

Description

@janpeterka

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.

Activity

grewn0uille

grewn0uille commented on Jan 12, 2022

@grewn0uille
Member

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

janpeterka

janpeterka commented on Jan 12, 2022

@janpeterka
Author

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

added a commit that references this issue on Jan 12, 2022
608de69
added this to the 54.1 milestone on Jan 12, 2022
added
crashProblems preventing documents from being rendered
on Jan 12, 2022
grewn0uille

grewn0uille commented on Jan 12, 2022

@grewn0uille
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.

PEMIDI

PEMIDI commented on Nov 16, 2024

@PEMIDI

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.

Same Issue, solved by downgrading to 53.4
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashProblems preventing documents from being rendered

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @janpeterka@grewn0uille@PEMIDI

        Issue actions

          Assertion Error in 54.0 · Issue #1538 · Kozea/WeasyPrint