#28 Assert fails


Using wordaxe 1.0.1.

The assert in NewParagraph.py:669 fails very often.

I don't understand the code well enough to figure it out, but something seriously bogus is going on.

Here's the code fragment:

self.width = availW
self.height = sumHeight
print sumHeight, availH
if sumHeight > availH:
assert not lineFrags, lineFrags
assert lines

Here's the values of sumHeight, availH and lines in one run of rst2pdf before the assert fails:

0 -5.62834645669 []

So, if I undestand correctly, there are no more lines, no space is required, and yet it's still trying to fit part of the unexistant remainder of the paragraph?

Hacking blindly it seems that changing the if to

if sumHeight > max(availH,0):

and removing the assert at the end of the method makes wordaxe work correctly, but I may be breaking everything in another way.


  • Comment has been marked as spam. 

    You can see all pending comments posted by this user  here

    Anonymous - 2010-03-26

    This is the patch suggested in the post, I have seen no bad side effects using it:

    < if sumHeight > availH:
    > if sumHeight and sumHeight > availH:
    < assert self.height <= availH, (id(self), self.height, availH)
    > #assert self.height <= availH, (id(self), self.height, availH)

  • H. von Bargen

    H. von Bargen - 2010-05-16

    I'm sorry that I didn't notice the issue earlier. I wish Sourceforge would notify me about new issues automatically.

    Can you pleae provide a test case? (for example an rst2pdf input file and your ReportLab and rst2pdf versions or whatever) that demonstrates the error?

    Interpreting your output "0 -5.62834645669 []" as
    sumHeight=0, availH=-0.56, lines=[], it seems to me as if the method i_wrap was called for an empty paragraph with a negative available space. This may be a consequence of an error elsewhere, for example the caching in wrap, an error in the split method, an error in rst2pdf or whatever.

    I think a more correct solution would be to pre-check availH and let i_wrap return (availW, 0) if availH < 0. Can you try it?

  • H. von Bargen

    H. von Bargen - 2011-01-22

    Applied the suggested patch to the trunk.

  • H. von Bargen

    H. von Bargen - 2011-01-22
    • status: open --> closed-fixed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks