Mercurial > p > roundup > code
comparison roundup/cgi/cgitb.py @ 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 | 64b05e24dbd8 |
| children | 86b6cea7a975 |
comparison
equal
deleted
inserted
replaced
| 5419:ef6631409171 | 5420:7172c201dec2 |
|---|---|
| 5 """Extended CGI traceback handler by Ka-Ping Yee, <ping@lfw.org>. | 5 """Extended CGI traceback handler by Ka-Ping Yee, <ping@lfw.org>. |
| 6 """ | 6 """ |
| 7 from __future__ import print_function | 7 from __future__ import print_function |
| 8 __docformat__ = 'restructuredtext' | 8 __docformat__ = 'restructuredtext' |
| 9 | 9 |
| 10 import sys, os, types, string, keyword, linecache, tokenize, inspect, cgi | 10 import sys, os, string, keyword, linecache, tokenize, inspect, cgi |
| 11 import pydoc, traceback | 11 import pydoc, traceback |
| 12 | 12 |
| 13 from roundup.cgi import templating, TranslationService | 13 from roundup.cgi import templating, TranslationService |
| 14 | 14 |
| 15 def get_translator(i18n=None): | 15 def get_translator(i18n=None): |
| 204 | 204 |
| 205 traceback.reverse() | 205 traceback.reverse() |
| 206 | 206 |
| 207 exception = '<p><strong>%s</strong>: %s' % (str(etype), str(evalue)) | 207 exception = '<p><strong>%s</strong>: %s' % (str(etype), str(evalue)) |
| 208 attribs = [] | 208 attribs = [] |
| 209 if type(evalue) is types.InstanceType: | 209 for name in dir(evalue): |
| 210 for name in dir(evalue): | 210 value = pydoc.html.repr(getattr(evalue, name)) |
| 211 value = pydoc.html.repr(getattr(evalue, name)) | 211 attribs.append('<br>%s%s = %s' % (indent, name, value)) |
| 212 attribs.append('<br>%s%s = %s' % (indent, name, value)) | |
| 213 | 212 |
| 214 return head + string.join(attribs) + string.join(traceback) + '<p> </p>' | 213 return head + string.join(attribs) + string.join(traceback) + '<p> </p>' |
| 215 | 214 |
| 216 def handler(): | 215 def handler(): |
| 217 print(breaker()) | 216 print(breaker()) |
