Unexpected alignment value causes an exception in dpl

19 views
Skip to first unread message

Vukan Ogrizović

unread,
Mar 7, 2025, 4:06:59 PMMar 7
to reportlab-users
If (as I miscellaneously done recently) some value other than TA_LEFT, TA_CENTER, TA_RIGHT, OR TA_JUSTIFY is assigned to adjustment variable when setting a flowable, a general exception (ValueError) is raised in platypus.py.

It is, as far as i see, caused by this code:

2531             if blPara.kind==0:
2532                 if alignment == TA_LEFT:
2533                     dpl = _leftDrawParaLine
2534                 elif alignment == TA_CENTER:
2535                     dpl = _centerDrawParaLine
2536                 elif alignment == TA_RIGHT:
2537                     dpl = _rightDrawParaLine
2538                 elif alignment == TA_JUSTIFY:
2539                     dpl = _justifyDrawParaLineRTL if isRTL else _justifyDrawParaLine

It would be reasonable to add an else branch with some default value, or to raise a more descriptive exception.

Reply all
Reply to author
Forward
0 new messages