reportlab: attempt to eliminate empty list argument issues bug contributed by Tim Roberts and Nate Silva
authorrgbecker
Wed, 02 Dec 2009 10:58:51 +0000
changeset 3272 10f6899a18a5
parent 3271 c14b161b62bf
child 3273 5a996758fbce
reportlab: attempt to eliminate empty list argument issues bug contributed by Tim Roberts and Nate Silva
src/reportlab/graphics/shapes.py
src/reportlab/platypus/doctemplate.py
src/reportlab/platypus/flowables.py
--- a/src/reportlab/graphics/shapes.py	Fri Nov 27 16:35:29 2009 +0000
+++ b/src/reportlab/graphics/shapes.py	Wed Dec 02 10:58:51 2009 +0000
@@ -1208,7 +1208,7 @@
     def __init__(self, points=[], **kw):
         SolidShape.__init__(self, kw)
         assert len(points) % 2 == 0, 'Point list must have even number of elements!'
-        self.points = points
+        self.points = points or []
 
     def copy(self):
         new = self.__class__(self.points)
@@ -1229,6 +1229,7 @@
 
     def __init__(self, points=[], **kw):
         LineShape.__init__(self, kw)
+        points = points or []
         lenPoints = len(points)
         if lenPoints:
             if type(points[0]) in (ListType,TupleType):
--- a/src/reportlab/platypus/doctemplate.py	Fri Nov 27 16:35:29 2009 +0000
+++ b/src/reportlab/platypus/doctemplate.py	Wed Dec 02 10:58:51 2009 +0000
@@ -245,6 +245,7 @@
     """
     def __init__(self,id=None,frames=[],onPage=_doNothing, onPageEnd=_doNothing,
                  pagesize=None):
+        frames = frames or []
         if type(frames) not in (ListType,TupleType): frames = [frames]
         assert filter(lambda x: not isinstance(x,Frame), frames)==[], "frames argument error"
         self.id = id
--- a/src/reportlab/platypus/flowables.py	Fri Nov 27 16:35:29 2009 +0000
+++ b/src/reportlab/platypus/flowables.py	Wed Dec 02 10:58:51 2009 +0000
@@ -890,7 +890,7 @@
         assert maxHeight>=0,  '%s invalid maxHeight value %s' % (self.identity(),maxHeight)
         if mergeSpace is None: mergeSpace = overlapAttachedSpace
         self.mergespace = mergeSpace
-        self._content = content
+        self._content = content or []
         self.vAlign = vAlign
         self.hAlign = hAlign
 
@@ -1144,7 +1144,7 @@
     _ZEROSIZE=1
     def __init__(self,nextTemplate,nextFrames=[],gap=10,required=72):
         self.nextTemplate=nextTemplate
-        self.nextFrames=nextFrames
+        self.nextFrames=nextFrames or []
         self.gap=gap
         self.required=required
 
@@ -1288,7 +1288,7 @@
     def __init__(self,cond,thenBlock,elseBlock=[]):
         Flowable.__init__(self)
         self.expr = cond
-        self.blocks = elseBlock,thenBlock
+        self.blocks = elseBlock or [],thenBlock
 
     def checkBlock(self,block):
         if not isinstance(block,(list,tuple)):