src/reportlab/platypus/tableofcontents.py
changeset 4551 d357e2acc856
parent 4528 e09377955af8
--- a/src/reportlab/platypus/tableofcontents.py	Thu Oct 24 15:53:59 2019 +0100
+++ b/src/reportlab/platypus/tableofcontents.py	Thu Oct 24 16:07:15 2019 +0100
@@ -2,7 +2,7 @@
 #see license.txt for license details
 #history https://hg.reportlab.com/hg-public/reportlab/log/tip/src/reportlab/platypus/tableofcontents.py
 
-__version__='3.3.0'
+__version__='3.5.32'
 __doc__="""Experimental class to generate Tables of Contents easily
 
 This module defines a single TableOfContents() class that can be used to
@@ -48,6 +48,7 @@
 from reportlab.lib.units import cm
 from reportlab.lib.utils import commasplit, escapeOnce, encode_label, decode_label, strTypes, asUnicode, asNative
 from reportlab.lib.styles import ParagraphStyle, _baseFontName
+from reportlab.lib import sequencer as rl_sequencer
 from reportlab.platypus.paragraph import Paragraph
 from reportlab.platypus.doctemplate import IndexingFlowable
 from reportlab.platypus.tables import TableStyle, Table
@@ -55,6 +56,7 @@
 from reportlab.pdfbase.pdfmetrics import stringWidth
 from reportlab.pdfgen import canvas
 import unicodedata
+from ast import literal_eval
 
 def unquote(txt):
     from xml.sax.saxutils import unescape
@@ -239,7 +241,7 @@
         def drawTOCEntryEnd(canvas, kind, label):
             '''Callback to draw dots and page numbers after each entry.'''
             label = label.split(',')
-            page, level, key = int(label[0]), int(label[1]), eval(label[2],{})
+            page, level, key = int(label[0]), int(label[1]), literal_eval(label[2])
             style = self.getLevelStyle(level)
             if self.dotsMinLevel >= 0 and level >= self.dotsMinLevel:
                 dot = ' . '
@@ -305,13 +307,11 @@
         self._flowable = None
         self.setup(**kwargs)
 
-    def getFormatFunc(self,format):
+    def getFormatFunc(self,formatName):
         try:
-            D = {}
-            exec('from reportlab.lib.sequencer import _format_%s as formatFunc' % format, D)
-            return D['formatFunc']
+            return getattr(rl_sequencer,'_format_%s' % formatName)
         except ImportError:
-            raise ValueError('Unknown format %r' % format)
+            raise ValueError('Unknown sequencer format %r' % formatName)
 
     def setup(self, style=None, dot=None, tableStyle=None, headers=True, name=None, format='123', offset=0):
         """