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

TypeError on column width expressed as percentage #731

Closed
JanEgner opened this issue Nov 8, 2023 · 1 comment · Fixed by #732
Closed

TypeError on column width expressed as percentage #731

JanEgner opened this issue Nov 8, 2023 · 1 comment · Fixed by #732
Labels
bug Something isn't working

Comments

@JanEgner
Copy link
Contributor

JanEgner commented Nov 8, 2023

Describe the Bug

After update to 0.2.12, unit tests involving xhtml2pdf started to fail with TypeError.

Expected Behavior

xhtml2pdf should work as before

Actual Behavior

Error with stack trace:

        for i, colWidth in enumerate(newColWidths):
            if (colWidth is not None) or (colWidth == "*"):
                newColWidth = self._normWidth(colWidth, totalWidth)
>               remainingWidth -= colWidth
E               TypeError: unsupported operand type(s) for -=: 'float' and 'str'

..\..\AppData\Local\Programs\Python\Python310\lib\site-packages\xhtml2pdf\xhtml2pdf_reportlab.py:832: TypeError

Patching the offending line to use newColWidth instead of colWidth resolves the error.

System Information

OS version: both Windows 10 and Linux
Python version: 3.10
XHTML2PDF version: 0.2.12

@viniciusd
Copy link

viniciusd commented Nov 8, 2023

Facing the same issue.

This bug was caused by a refactoring when the ruff linter was added:

a3211b8#diff-74f01775643512741726dc5b4de3062a970be3ce0a07bd148192173000fb872dL822

Some minimal HTML that triggers it:

<html>
<head>
    <meta charset="utf-8">
    <style>
        td { width: 80% }
    </style>
</head>
<body>
    <table>
        <tbody>
                <tr>
                    <td>Foo</td>
                </tr>
        </tbody>
    </table>
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants