Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 57b39e0

Browse files
committed
Bug #1697782: remove all remaining code that uses types.InstanceType.
1 parent b5ddcfd commit 57b39e0

8 files changed

Lines changed: 10 additions & 38 deletions

File tree

Lib/cgitb.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,10 @@ def reader(lnum=[lnum]):
167167

168168
exception = ['<p>%s: %s' % (strong(pydoc.html.escape(str(etype))),
169169
pydoc.html.escape(str(evalue)))]
170-
if type(evalue) is types.InstanceType:
171-
for name in dir(evalue):
172-
if name[:1] == '_': continue
173-
value = pydoc.html.repr(getattr(evalue, name))
174-
exception.append('\n<br>%s%s&nbsp;=\n%s' % (indent, name, value))
170+
for name in dir(evalue):
171+
if name[:1] == '_': continue
172+
value = pydoc.html.repr(getattr(evalue, name))
173+
exception.append('\n<br>%s%s&nbsp;=\n%s' % (indent, name, value))
175174

176175
import traceback
177176
return head + ''.join(frames) + ''.join(exception) + '''
@@ -239,10 +238,9 @@ def reader(lnum=[lnum]):
239238
frames.append('\n%s\n' % '\n'.join(rows))
240239

241240
exception = ['%s: %s' % (str(etype), str(evalue))]
242-
if type(evalue) is types.InstanceType:
243-
for name in dir(evalue):
244-
value = pydoc.text.repr(getattr(evalue, name))
245-
exception.append('\n%s%s = %s' % (" "*4, name, value))
241+
for name in dir(evalue):
242+
value = pydoc.text.repr(getattr(evalue, name))
243+
exception.append('\n%s%s = %s' % (" "*4, name, value))
246244

247245
import traceback
248246
return head + ''.join(frames) + ''.join(exception) + '''

Lib/idlelib/ObjectBrowser.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ def GetSubList(self):
5757
sublist.append(item)
5858
return sublist
5959

60-
class InstanceTreeItem(ObjectTreeItem):
61-
def IsExpandable(self):
62-
return True
63-
def GetSubList(self):
64-
sublist = ObjectTreeItem.GetSubList(self)
65-
sublist.insert(0,
66-
make_objecttreeitem("__class__ =", self.object.__class__))
67-
return sublist
68-
6960
class ClassTreeItem(ObjectTreeItem):
7061
def IsExpandable(self):
7162
return True
@@ -120,7 +111,6 @@ def keys(self):
120111
TupleType: SequenceTreeItem,
121112
ListType: SequenceTreeItem,
122113
DictType: DictTreeItem,
123-
InstanceType: InstanceTreeItem,
124114
ClassType: ClassTreeItem,
125115
}
126116

Lib/idlelib/rpc.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,6 @@ def _getmethods(obj, methods):
574574
attr = getattr(obj, name)
575575
if callable(attr):
576576
methods[name] = 1
577-
if type(obj) == types.InstanceType:
578-
_getmethods(obj.__class__, methods)
579577
if type(obj) == types.ClassType:
580578
for super in obj.__bases__:
581579
_getmethods(super, methods)

Lib/plat-mac/aetypes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ def __str__(self):
518518
ss = repr(seld)
519519
elif IsRange(seld):
520520
start, stop = seld.start, seld.stop
521-
if type(start) == InstanceType == type(stop) and \
522-
start.__class__ == self.__class__ == stop.__class__:
521+
if type(start) == type(stop) == type(self):
523522
ss = str(start.seld) + " thru " + str(stop.seld)
524523
else:
525524
ss = str(seld)

Lib/plat-mac/findertools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ def windowposition(folder, pos=None):
484484
openwindow(fsr)
485485
if not pos:
486486
return _getwindowposition(folder_alias)
487-
if type(pos) == InstanceType:
488-
# pos might be a QDPoint object as returned by _getwindowposition
487+
if aetypes.IsQDPoint(pos):
488+
# QDPoint object as returned by _getwindowposition
489489
pos = (pos.h, pos.v)
490490
return _setwindowposition(folder_alias, pos)
491491

Lib/pydoc.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,8 +1433,6 @@ def describe(thing):
14331433
return 'function ' + thing.__name__
14341434
if inspect.ismethod(thing):
14351435
return 'method ' + thing.__name__
1436-
if type(thing) is types.InstanceType:
1437-
return 'instance of ' + thing.__class__.__name__
14381436
return type(thing).__name__
14391437

14401438
def locate(path, forceload=0):

Lib/test/crashers/infinite_rec_5.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

Lib/test/test_isinstance.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class TestIsInstanceExceptions(unittest.TestCase):
1515
# (leading to an "undetected error" in the debug build). Set up is,
1616
# isinstance(inst, cls) where:
1717
#
18-
# - inst isn't an InstanceType
1918
# - cls isn't a ClassType, a TypeType, or a TupleType
2019
# - cls has a __bases__ attribute
2120
# - inst has a __class__ attribute

0 commit comments

Comments
 (0)