[reportlab-users] Possible bug?

Robin Becker robin at reportlab.com
Sat Mar 19 05:08:38 EDT 2022


On 16/03/2022 13:18, Les wrote:
>>
>> 2) there is no guarantee that any specific flowable is immutable; to
>> support repeated processing we make a shallow copy
>> and that works for many cases, but it's not guaranteed if the flowables
>> are perverse. Shallow and deep copies may allow
>> duplicated usage, but obviously they consume resources.
>>
> 
> Hello Robin,
> 
> I understand the explanation. Just one more question. Nothing is perverse
> in my minimal working example, it only contains simple paragraphs. You also
> say that generally it is disallowed to use shallow copies for repeated
> document generation.
> 
> However, BaseDocTemplate.multiBuild also uses a shallow copy:
> 
> https://github.com/Distrotech/reportlab/blob/master/src/reportlab/platypus/doctemplate.py#L1042
> 
> # work with a copy of the story, since it is consumed
> tempStory = story[:]
> self.build(tempStory, **buildKwds)
> 
> I'm curious - why is it allowed here, and not allowed elsewhere?
> 
>.......
2) explicitly says "if the flowables are perverse". Nobody is disallowing use of shallow copies, but they are not 
guaranteed. If flowables lacked internal state things would work more easily. Python allows foot shooting :(

The life cycle of flowables ought to be more complex than just wrap & draw, but it's too late now.
--
Robin Becker


More information about the reportlab-users mailing list