remove ascii, cmp & xrange builtins abuse; version-->3.4.15
authorrobin <robin@reportlab.com>
Wed, 27 Sep 2017 11:04:12 +0100
changeset 4367 9960d82643bf
parent 4366 ddf3d4f5066a
child 4368 c088826211ca
remove ascii, cmp & xrange builtins abuse; version-->3.4.15
src/reportlab/__init__.py
src/reportlab/graphics/charts/axes.py
src/reportlab/graphics/charts/barcharts.py
src/reportlab/graphics/charts/legends.py
src/reportlab/graphics/charts/piecharts.py
src/reportlab/graphics/renderPDF.py
src/reportlab/graphics/renderPM.py
src/reportlab/graphics/renderPS.py
src/reportlab/graphics/renderSVG.py
src/reportlab/graphics/shapes.py
src/reportlab/lib/attrmap.py
src/reportlab/lib/colors.py
src/reportlab/lib/normalDate.py
src/reportlab/lib/pdfencrypt.py
src/reportlab/lib/testutils.py
src/reportlab/lib/validators.py
src/reportlab/pdfbase/acroform.py
src/reportlab/pdfbase/pdfdoc.py
src/reportlab/pdfbase/pdfmetrics.py
src/reportlab/pdfbase/pdfpattern.py
src/reportlab/pdfbase/ttfonts.py
src/reportlab/pdfgen/canvas.py
src/reportlab/platypus/doctemplate.py
src/reportlab/platypus/flowables.py
src/reportlab/platypus/paragraph.py
src/reportlab/platypus/paraparser.py
src/reportlab/platypus/tables.py
tests/test_lib_colors.py
tests/test_multibyte_jpn.py
tests/test_paragraphs.py
tests/test_pdfbase_pdfform.py
tests/test_pdfbase_pdfutils.py
tests/test_platypus_index.py
tests/test_renderSVG.py
tests/test_rl_accel.py
--- a/src/reportlab/__init__.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/__init__.py	Wed Sep 27 11:04:12 2017 +0100
@@ -1,9 +1,9 @@
 #Copyright ReportLab Europe Ltd. 2000-2017
 #see license.txt for license details
 __doc__="""The Reportlab PDF generation library."""
-Version = "3.4.14"
+Version = "3.4.15"
 __version__=Version
-__date__='20170526'
+__date__='20170927'
 
 import sys, os
 
@@ -15,11 +15,9 @@
 if isPy3:
     def cmp(a,b):
         return -1 if a<b else (1 if a>b else 0)
+    xrange = range
+    ascii = ascii
 
-    import builtins
-    builtins.cmp = cmp
-    builtins.xrange = range
-    del cmp, builtins
     def _fake_import(fn,name):
         from importlib import machinery
         m = machinery.SourceFileLoader(name,fn)
@@ -29,9 +27,8 @@
             raise ImportError('file %s not found' % ascii(fn))
 else:
     from future_builtins import ascii
-    import __builtin__
-    __builtin__.ascii = ascii
-    del ascii, __builtin__
+    xrange = xrange
+    cmp = cmp
     def _fake_import(fn,name):
         if os.path.isfile(fn):
             import imp
--- a/src/reportlab/graphics/charts/axes.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/graphics/charts/axes.py	Wed Sep 27 11:04:12 2017 +0100
@@ -44,6 +44,7 @@
 from reportlab.graphics.widgets.grids import ShadedRect
 from reportlab.lib.colors import Color
 from reportlab.lib.utils import isSeq
+from reportlab import xrange
 import copy
 try:
     reduce  # Python 2.x
--- a/src/reportlab/graphics/charts/barcharts.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/graphics/charts/barcharts.py	Wed Sep 27 11:04:12 2017 +0100
@@ -25,6 +25,7 @@
 from reportlab.graphics.charts.textlabels import BarChartLabel, NA_Label, NoneOrInstanceOfNA_Label
 from reportlab.graphics.charts.areas import PlotArea
 from reportlab.graphics.charts.legends import _objStr
+from reportlab import xrange, cmp
 
 class BarChartProperties(PropHolder):
     _attrMap = AttrMap(
--- a/src/reportlab/graphics/charts/legends.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/graphics/charts/legends.py	Wed Sep 27 11:04:12 2017 +0100
@@ -20,6 +20,7 @@
 from reportlab.lib.utils import isSeq, find_locals
 from reportlab.graphics.shapes import _baseGFontName
 from functools import reduce
+from reportlab import xrange
 
 def _transMax(n,A):
     X = n*[0]
--- a/src/reportlab/graphics/charts/piecharts.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/graphics/charts/piecharts.py	Wed Sep 27 11:04:12 2017 +0100
@@ -33,6 +33,7 @@
 from reportlab.graphics.charts.areas import PlotArea
 from reportlab.graphics.charts.legends import _objStr
 from reportlab.graphics.charts.textlabels import Label
+from reportlab import xrange, ascii, cmp
 
 _ANGLE2BOXANCHOR={0:'w', 45:'sw', 90:'s', 135:'se', 180:'e', 225:'ne', 270:'n', 315: 'nw', -45: 'nw'}
 _ANGLE2RBOXANCHOR={0:'e', 45:'ne', 90:'n', 135:'nw', 180:'w', 225:'sw', 270:'s', 315: 'se', -45: 'se'}
--- a/src/reportlab/graphics/renderPDF.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/graphics/renderPDF.py	Wed Sep 27 11:04:12 2017 +0100
@@ -19,7 +19,7 @@
 from reportlab.pdfgen.canvas import Canvas
 from reportlab.pdfbase.pdfmetrics import stringWidth
 from reportlab.lib.utils import getBytesIO
-from reportlab import rl_config
+from reportlab import ascii, rl_config
 from reportlab.graphics.renderbase import Renderer, StateTracker, getStateDelta, renderScaledDrawing, STATE_DEFAULTS
 
 # the main entry point for users...
--- a/src/reportlab/graphics/renderPM.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/graphics/renderPM.py	Wed Sep 27 11:04:12 2017 +0100
@@ -17,7 +17,7 @@
 from reportlab.pdfbase.pdfmetrics import getFont, unicode2T1
 from math import sin, cos, pi, ceil
 from reportlab.lib.utils import getStringIO, getBytesIO, open_and_read, isUnicode
-from reportlab import rl_config
+from reportlab import rl_config, ascii
 
 class RenderPMError(Exception):
     pass
--- a/src/reportlab/graphics/renderPS.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/graphics/renderPS.py	Wed Sep 27 11:04:12 2017 +0100
@@ -12,7 +12,7 @@
 from reportlab.graphics.shapes import STATE_DEFAULTS
 import math
 from operator import getitem
-from reportlab import rl_config
+from reportlab import rl_config, xrange, ascii
 from reportlab.pdfgen.canvas import FILL_EVEN_ODD, FILL_NON_ZERO
 _ESCAPEDICT={}
 for c in xrange(256):
--- a/src/reportlab/graphics/renderSVG.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/graphics/renderSVG.py	Wed Sep 27 11:04:12 2017 +0100
@@ -17,7 +17,7 @@
 from reportlab.graphics.renderbase import StateTracker, getStateDelta, Renderer, renderScaledDrawing
 from reportlab.graphics.shapes import STATE_DEFAULTS, Path, UserNode
 from reportlab.graphics.shapes import * # (only for test0)
-from reportlab import rl_config
+from reportlab import rl_config, ascii
 from reportlab.lib.utils import getStringIO, RLString, isPy3, isUnicode, isBytes
 from reportlab.pdfgen.canvas import FILL_EVEN_ODD, FILL_NON_ZERO
 
--- a/src/reportlab/graphics/shapes.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/graphics/shapes.py	Wed Sep 27 11:04:12 2017 +0100
@@ -21,6 +21,7 @@
 from reportlab.pdfbase.pdfmetrics import stringWidth
 from reportlab.lib.fonts import tt2ps
 from reportlab.pdfgen.canvas import FILL_EVEN_ODD, FILL_NON_ZERO
+from reportlab import xrange
 _baseGFontNameB = tt2ps(_baseGFontName,1,0)
 _baseGFontNameI = tt2ps(_baseGFontName,0,1)
 _baseGFontNameBI = tt2ps(_baseGFontName,1,1)
--- a/src/reportlab/lib/attrmap.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/lib/attrmap.py	Wed Sep 27 11:04:12 2017 +0100
@@ -30,7 +30,7 @@
 '''
 from reportlab.lib.validators import isAnything, DerivedValue
 from reportlab.lib.utils import isSeq
-from reportlab import rl_config
+from reportlab import rl_config, ascii
 
 class CallableValue:
     '''a class to allow callable initial values'''
--- a/src/reportlab/lib/colors.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/lib/colors.py	Wed Sep 27 11:04:12 2017 +0100
@@ -40,7 +40,7 @@
 ValueError: css color 'pcmyka(100,0,0,0)' has wrong number of components
 '''
 import math, re, functools
-from reportlab import isPy3
+from reportlab import isPy3, cmp
 from reportlab.lib.rl_accel import fp_str
 from reportlab.lib.utils import asNative, isStr
 import collections
--- a/src/reportlab/lib/normalDate.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/lib/normalDate.py	Wed Sep 27 11:04:12 2017 +0100
@@ -25,6 +25,7 @@
 _monthNameLower = _monthName.lower().split()
 _monthNameLower = _monthName.split()
 
+from reportlab import cmp
 import re, time, datetime
 from .utils import isPy3, isStr
 
--- a/src/reportlab/lib/pdfencrypt.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/lib/pdfencrypt.py	Wed Sep 27 11:04:12 2017 +0100
@@ -9,7 +9,7 @@
 from reportlab.pdfbase import pdfutils
 from reportlab.pdfbase.pdfdoc import PDFObject
 from reportlab.platypus.flowables import Flowable
-from reportlab import rl_config
+from reportlab import rl_config, ascii
 
 #AR debug hooks - leaving in for now
 CLOBBERID = 0  # set a constant Doc ID to allow comparison with other software like iText
--- a/src/reportlab/lib/testutils.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/lib/testutils.py	Wed Sep 27 11:04:12 2017 +0100
@@ -19,6 +19,7 @@
     from ConfigParser import ConfigParser
 import unittest
 from reportlab.lib.utils import isCompactDistro, __rl_loader__, rl_isdir, asUnicode
+from reportlab import ascii
 
 # Helper functions.
 def isWritable(D):
--- a/src/reportlab/lib/validators.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/lib/validators.py	Wed Sep 27 11:04:12 2017 +0100
@@ -7,6 +7,7 @@
 import sys, codecs
 from reportlab.lib.utils import isSeq, isBytes, isStr, isPy3
 from reportlab.lib import colors
+from reportlab import ascii
 
 class Percentage(float):
     pass
--- a/src/reportlab/pdfbase/acroform.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/pdfbase/acroform.py	Wed Sep 27 11:04:12 2017 +0100
@@ -5,6 +5,7 @@
 from reportlab.lib.colors import Color, CMYKColor, Whiter, Blacker
 from reportlab.lib.rl_accel import fp_str
 from reportlab.lib.utils import isStr, asNative
+from reportlab import xrange
 import weakref
 
 visibilities = dict(
--- a/src/reportlab/pdfbase/pdfdoc.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/pdfbase/pdfdoc.py	Wed Sep 27 11:04:12 2017 +0100
@@ -17,7 +17,7 @@
 import types, binascii, codecs, time
 from collections import OrderedDict
 from reportlab.pdfbase import pdfutils
-from reportlab import rl_config
+from reportlab import rl_config, ascii
 from reportlab.lib.utils import import_zlib, open_for_read, makeFileName, isSeq, isBytes, isUnicode, _digester, isStr, bytestr, isPy3, annotateException, TimeStamp
 from reportlab.lib.rl_accel import escapePDF, fp_str, asciiBase85Encode, asciiBase85Decode
 from reportlab.pdfbase import pdfmetrics
--- a/src/reportlab/pdfbase/pdfmetrics.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/pdfbase/pdfmetrics.py	Wed Sep 27 11:04:12 2017 +0100
@@ -25,6 +25,7 @@
 from reportlab.rl_config import defaultEncoding, T1SearchPath
 from reportlab.lib.rl_accel import unicode2T1, instanceStringWidthT1
 from reportlab.pdfbase import rl_codecs
+from reportlab import ascii
 _notdefChar = b'n'
 
 rl_codecs.RL_Codecs.register()
--- a/src/reportlab/pdfbase/pdfpattern.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/pdfbase/pdfpattern.py	Wed Sep 27 11:04:12 2017 +0100
@@ -1,6 +1,7 @@
 __doc__="""helper for importing pdf structures into a ReportLab generated document
 """
 from reportlab.pdfbase.pdfdoc import format, PDFObject, pdfdocEnc
+from reportlab import ascii
 from reportlab.lib.utils import strTypes
 
 def _patternSequenceCheck(pattern_sequence):
--- a/src/reportlab/pdfbase/ttfonts.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/pdfbase/ttfonts.py	Wed Sep 27 11:04:12 2017 +0100
@@ -54,7 +54,7 @@
 from struct import pack, unpack, error as structError
 from reportlab.lib.utils import getBytesIO, isPy3, bytestr, isUnicode, char2int
 from reportlab.pdfbase import pdfmetrics, pdfdoc
-from reportlab import rl_config
+from reportlab import rl_config, xrange, ascii
 from reportlab.lib.rl_accel import hex32, add32, calcChecksum, instanceStringWidthTTF
 from collections import namedtuple
 import os, time
--- a/src/reportlab/pdfgen/canvas.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/pdfgen/canvas.py	Wed Sep 27 11:04:12 2017 +0100
@@ -16,7 +16,7 @@
 from string import digits
 import tempfile
 from math import sin, cos, tan, pi, ceil
-from reportlab import rl_config
+from reportlab import rl_config, ascii
 from reportlab.pdfbase import pdfutils
 from reportlab.pdfbase import pdfdoc
 from reportlab.pdfbase import pdfmetrics
--- a/src/reportlab/platypus/doctemplate.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/platypus/doctemplate.py	Wed Sep 27 11:04:12 2017 +0100
@@ -37,6 +37,7 @@
 import reportlab.lib.sequencer
 from reportlab.pdfgen import canvas
 from reportlab.lib.utils import isSeq, encode_label, decode_label, annotateException, strTypes
+from reportlab import ascii
 
 try:
     set
--- a/src/reportlab/platypus/flowables.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/platypus/flowables.py	Wed Sep 27 11:04:12 2017 +0100
@@ -34,6 +34,7 @@
 from reportlab.pdfbase import pdfutils
 from reportlab.pdfbase.pdfmetrics import stringWidth
 from reportlab.rl_config import _FUZZ, overlapAttachedSpace, ignoreContainerActions, listWrapOnFakeWidth
+from reportlab import xrange
 import collections
 
 __all__ = '''TraceInfo Flowable XBox Preformatted Image NullDraw Spacer UseUpSpace PageBreak SlowPageBreak
--- a/src/reportlab/platypus/paragraph.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/platypus/paragraph.py	Wed Sep 27 11:04:12 2017 +0100
@@ -18,6 +18,7 @@
 from reportlab.rl_config import platypus_link_underline, decimalSymbol, _FUZZ, paraFontSizeHeightOffset
 from reportlab.lib.utils import _className, isBytes, unicodeT, bytesT, strTypes
 from reportlab.lib.rl_accel import sameFrag
+from reportlab import xrange
 import re
 from types import MethodType
 
--- a/src/reportlab/platypus/paraparser.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/platypus/paraparser.py	Wed Sep 27 11:04:12 2017 +0100
@@ -10,6 +10,7 @@
 import copy
 import base64
 from pprint import pprint as pp
+from reportlab import ascii
 import unicodedata
 import reportlab.lib.sequencer
 
--- a/src/reportlab/platypus/tables.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/src/reportlab/platypus/tables.py	Wed Sep 27 11:04:12 2017 +0100
@@ -18,7 +18,7 @@
 tables and table styles.
 """
 from reportlab.platypus.flowables import Flowable, Preformatted, Spacer
-from reportlab import rl_config
+from reportlab import rl_config, xrange, ascii
 from reportlab.lib.styles import PropertySet, ParagraphStyle, _baseFontName
 from reportlab.lib import colors
 from reportlab.lib.utils import annotateException, IdentStr, flatten, isStr, asNative, strTypes
--- a/tests/test_lib_colors.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/tests/test_lib_colors.py	Wed Sep 27 11:04:12 2017 +0100
@@ -3,6 +3,7 @@
 """Tests for the reportlab.lib.colors module.
 """
 __version__='3.3.0'
+from reportlab import ascii
 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
 setOutDir(__name__)
 import os, math
--- a/tests/test_multibyte_jpn.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/tests/test_multibyte_jpn.py	Wed Sep 27 11:04:12 2017 +0100
@@ -6,6 +6,7 @@
 The code in this module will disappear any day now and be replaced
 by classes in reportlab.pdfbase.cidfonts
 """
+from reportlab import ascii
 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
 setOutDir(__name__)
 import string, os
--- a/tests/test_paragraphs.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/tests/test_paragraphs.py	Wed Sep 27 11:04:12 2017 +0100
@@ -2,6 +2,7 @@
 #see license.txt for license details
 # tests some paragraph styles
 __version__='3.3.0'
+from reportlab import xrange
 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
 setOutDir(__name__)
 import unittest
--- a/tests/test_pdfbase_pdfform.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/tests/test_pdfbase_pdfform.py	Wed Sep 27 11:04:12 2017 +0100
@@ -1,3 +1,4 @@
+from reportlab import xrange
 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation, NearTestCase
 setOutDir(__name__)
 import unittest
--- a/tests/test_pdfbase_pdfutils.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/tests/test_pdfbase_pdfutils.py	Wed Sep 27 11:04:12 2017 +0100
@@ -3,6 +3,7 @@
 """Tests for utility functions in reportlab.pdfbase.pdfutils.
 """
 __version__='3.3.0'
+from reportlab import xrange
 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, printLocation
 setOutDir(__name__)
 import os
--- a/tests/test_platypus_index.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/tests/test_platypus_index.py	Wed Sep 27 11:04:12 2017 +0100
@@ -3,6 +3,7 @@
 """Tests for the Platypus SimpleIndex and AlphabeticIndex classes.
 """
 __version__='3.3.0'
+from reportlab import xrange
 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
 setOutDir(__name__)
 import sys, os
--- a/tests/test_renderSVG.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/tests/test_renderSVG.py	Wed Sep 27 11:04:12 2017 +0100
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+from reportlab import ascii
 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
 setOutDir(__name__)
 import sys
--- a/tests/test_rl_accel.py	Fri Jun 23 14:01:44 2017 +0100
+++ b/tests/test_rl_accel.py	Wed Sep 27 11:04:12 2017 +0100
@@ -1,5 +1,6 @@
 __version__='3.3.0'
 __doc__='''basic tests.'''
+from reportlab import xrange, ascii
 from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, printLocation
 from reportlab.lib.utils import asBytes, isPyPy
 setOutDir(__name__)