changeset 5420:7172c201dec2

Python 3 preparation: avoid obsolete types.*Type names. There are references to types.ListType (not actually used), types.TupleType (for which tuple is a sufficient replacement) and types.InstanceType (also removed from the types module in Python 3, it was the type of instances of old-style classes only). Where InstanceType is used it's testing whether an exception is a class or not; support for non-class exceptions was removed in Python 3 and patch 3 in this series removed the sole instance of one in Roundup, so making the code in question unconditional seems reasonable.
author Joseph Myers <jsm@polyomino.org.uk>
date Wed, 25 Jul 2018 09:10:46 +0000
parents ef6631409171
children 45bfb4bf59c2
files roundup/cgi/TAL/TALDefs.py roundup/cgi/TAL/TALInterpreter.py roundup/cgi/cgitb.py
diffstat 3 files changed, 6 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/cgi/TAL/TALDefs.py	Wed Jul 25 09:09:28 2018 +0000
+++ b/roundup/cgi/TAL/TALDefs.py	Wed Jul 25 09:10:46 2018 +0000
@@ -17,8 +17,6 @@
 Common definitions used by TAL and METAL compilation an transformation.
 """
 
-from types import ListType, TupleType
-
 #from ITALES import ITALESErrorInfo
 
 TAL_VERSION = "1.4"
@@ -156,7 +154,7 @@
 
 def getProgramMode(program):
     version = getProgramVersion(program)
-    if (version == TAL_VERSION and isinstance(program[1], TupleType) and
+    if (version == TAL_VERSION and isinstance(program[1], tuple) and
         len(program[1]) == 2):
         opcode, mode = program[1]
         if opcode == "mode":
@@ -165,7 +163,7 @@
 
 def getProgramVersion(program):
     if (len(program) >= 2 and
-        isinstance(program[0], TupleType) and len(program[0]) == 2):
+        isinstance(program[0], tuple) and len(program[0]) == 2):
         opcode, version = program[0]
         if opcode == "version":
             return version
--- a/roundup/cgi/TAL/TALInterpreter.py	Wed Jul 25 09:09:28 2018 +0000
+++ b/roundup/cgi/TAL/TALInterpreter.py	Wed Jul 25 09:10:46 2018 +0000
@@ -20,7 +20,6 @@
 import sys
 import getopt
 import re
-from types import ListType
 from cgi import escape
 from roundup.anypy.strings import StringIO
 #from DocumentTemplate.DT_Util import ustr
--- a/roundup/cgi/cgitb.py	Wed Jul 25 09:09:28 2018 +0000
+++ b/roundup/cgi/cgitb.py	Wed Jul 25 09:10:46 2018 +0000
@@ -7,7 +7,7 @@
 from __future__ import print_function
 __docformat__ = 'restructuredtext'
 
-import sys, os, types, string, keyword, linecache, tokenize, inspect, cgi
+import sys, os, string, keyword, linecache, tokenize, inspect, cgi
 import pydoc, traceback
 
 from roundup.cgi import templating, TranslationService
@@ -206,10 +206,9 @@
 
     exception = '<p><strong>%s</strong>: %s' % (str(etype), str(evalue))
     attribs = []
-    if type(evalue) is types.InstanceType:
-        for name in dir(evalue):
-            value = pydoc.html.repr(getattr(evalue, name))
-            attribs.append('<br>%s%s&nbsp;= %s' % (indent, name, value))
+    for name in dir(evalue):
+        value = pydoc.html.repr(getattr(evalue, name))
+        attribs.append('<br>%s%s&nbsp;= %s' % (indent, name, value))
 
     return head + string.join(attribs) + string.join(traceback) + '<p>&nbsp;</p>'
 

Roundup Issue Tracker: http://roundup-tracker.org/