[reportlab-users] Assertion error in platypus.Table._calcPreliminaryWidths

Kirby, Dave Dave_Kirby at bmc.com
Tue Aug 30 12:37:18 EDT 2011


I am generating a PDF that has lots of tables in it, and am getting an assertion failure platypus.Table._calcPreliminaryWidths method. Here is the tail end of the traceback:

File "/usr/tideway/lib/python2.7/site-packages/reportlab/platypus/flowables.py", line 503, in _listWrapOn
w,h = f.wrapOn(canv,availWidth,0xfffffff)
File "/usr/tideway/lib/python2.7/site-packages/reportlab/platypus/flowables.py", line 119, in wrapOn
w, h = self.wrap(aW,aH)
File "/usr/tideway/lib/python2.7/site-packages/reportlab/platypus/tables.py", line 1113, in wrap
self._calc(availWidth, availHeight)
File "/usr/tideway/lib/python2.7/site-packages/reportlab/platypus/tables.py", line 571, in _calc
W = self._calcPreliminaryWidths(availWidth) #widths
File "/usr/tideway/lib/python2.7/site-packages/reportlab/platypus/tables.py", line 762, in _calcPreliminaryWidths
assert adjusted >= minimum
AssertionError

The values that caused the assertion were adjusted = 38.3227472747 and minimum = 40.8037109375. The method was called with availWidth = 484.06 and self._argW = ['28.28%', '28.28%', '28.28%', '*']. There was nothing unusual that I could see in the text data, so I am baffled as to why it asserted.

Has anyone else seen this problem? Does the assertion indicate a bug in the reportlab code or in my calling code?

If I comment out the assert statement everything seems to work OK, so I am wondering if the assertion is important or if I could subclass Table and override _calcPreliminaryWidths to remove it - is that likely to cause other problems further down the line?

There are a lot of tables in the PDF I am generating so I am currently trying to figure out which table caused the problem and create a smaller test case that I can post here.

Any help would be appreciated.

Dave Kirby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20110830/ade60d1f/attachment.html>


More information about the reportlab-users mailing list