Skip to content

Commit 9bd09e4

Browse files
committed
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.
1 parent 84271d3 commit 9bd09e4

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

roundup/cgi/TAL/TALDefs.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
Common definitions used by TAL and METAL compilation an transformation.
1818
"""
1919

20-
from types import ListType, TupleType
21-
2220
#from ITALES import ITALESErrorInfo
2321

2422
TAL_VERSION = "1.4"
@@ -156,7 +154,7 @@ def isCurrentVersion(program):
156154

157155
def getProgramMode(program):
158156
version = getProgramVersion(program)
159-
if (version == TAL_VERSION and isinstance(program[1], TupleType) and
157+
if (version == TAL_VERSION and isinstance(program[1], tuple) and
160158
len(program[1]) == 2):
161159
opcode, mode = program[1]
162160
if opcode == "mode":
@@ -165,7 +163,7 @@ def getProgramMode(program):
165163

166164
def getProgramVersion(program):
167165
if (len(program) >= 2 and
168-
isinstance(program[0], TupleType) and len(program[0]) == 2):
166+
isinstance(program[0], tuple) and len(program[0]) == 2):
169167
opcode, version = program[0]
170168
if opcode == "version":
171169
return version

roundup/cgi/TAL/TALInterpreter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import sys
2121
import getopt
2222
import re
23-
from types import ListType
2423
from cgi import escape
2524
from roundup.anypy.strings import StringIO
2625
#from DocumentTemplate.DT_Util import ustr

roundup/cgi/cgitb.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from __future__ import print_function
88
__docformat__ = 'restructuredtext'
99

10-
import sys, os, types, string, keyword, linecache, tokenize, inspect, cgi
10+
import sys, os, string, keyword, linecache, tokenize, inspect, cgi
1111
import pydoc, traceback
1212

1313
from roundup.cgi import templating, TranslationService
@@ -206,10 +206,9 @@ def linereader(file=file, lnum=[lnum]):
206206

207207
exception = '<p><strong>%s</strong>: %s' % (str(etype), str(evalue))
208208
attribs = []
209-
if type(evalue) is types.InstanceType:
210-
for name in dir(evalue):
211-
value = pydoc.html.repr(getattr(evalue, name))
212-
attribs.append('<br>%s%s&nbsp;= %s' % (indent, name, value))
209+
for name in dir(evalue):
210+
value = pydoc.html.repr(getattr(evalue, name))
211+
attribs.append('<br>%s%s&nbsp;= %s' % (indent, name, value))
213212

214213
return head + string.join(attribs) + string.join(traceback) + '<p>&nbsp;</p>'
215214

0 commit comments

Comments
 (0)