]> granicus.if.org Git - python/commitdiff
Bug #1697782: remove all remaining code that uses types.InstanceType.
authorGeorg Brandl <georg@python.org>
Wed, 11 Apr 2007 19:24:50 +0000 (19:24 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 11 Apr 2007 19:24:50 +0000 (19:24 +0000)
Lib/cgitb.py
Lib/idlelib/ObjectBrowser.py
Lib/idlelib/rpc.py
Lib/plat-mac/aetypes.py
Lib/plat-mac/findertools.py
Lib/pydoc.py
Lib/test/crashers/infinite_rec_5.py [deleted file]
Lib/test/test_isinstance.py

index ae25cf13ad7ba9670464d2821ae80e9f47eb3d2f..19118ea53d4a42fd3f8c0260d44fdfa02dd7b31d 100644 (file)
@@ -167,11 +167,10 @@ function calls leading up to the error, in the order they occurred.</p>'''
 
     exception = ['<p>%s: %s' % (strong(pydoc.html.escape(str(etype))),
                                 pydoc.html.escape(str(evalue)))]
-    if type(evalue) is types.InstanceType:
-        for name in dir(evalue):
-            if name[:1] == '_': continue
-            value = pydoc.html.repr(getattr(evalue, name))
-            exception.append('\n<br>%s%s&nbsp;=\n%s' % (indent, name, value))
+    for name in dir(evalue):
+        if name[:1] == '_': continue
+        value = pydoc.html.repr(getattr(evalue, name))
+        exception.append('\n<br>%s%s&nbsp;=\n%s' % (indent, name, value))
 
     import traceback
     return head + ''.join(frames) + ''.join(exception) + '''
@@ -239,10 +238,9 @@ function calls leading up to the error, in the order they occurred.
         frames.append('\n%s\n' % '\n'.join(rows))
 
     exception = ['%s: %s' % (str(etype), str(evalue))]
-    if type(evalue) is types.InstanceType:
-        for name in dir(evalue):
-            value = pydoc.text.repr(getattr(evalue, name))
-            exception.append('\n%s%s = %s' % (" "*4, name, value))
+    for name in dir(evalue):
+        value = pydoc.text.repr(getattr(evalue, name))
+        exception.append('\n%s%s = %s' % (" "*4, name, value))
 
     import traceback
     return head + ''.join(frames) + ''.join(exception) + '''
index b4f64b6fb24d25937e1a9e37b42ce7311fc35802..3ef5bb905de26197c40f49aad3cc790782534b4c 100644 (file)
@@ -57,15 +57,6 @@ class ObjectTreeItem(TreeItem):
             sublist.append(item)
         return sublist
 
-class InstanceTreeItem(ObjectTreeItem):
-    def IsExpandable(self):
-        return True
-    def GetSubList(self):
-        sublist = ObjectTreeItem.GetSubList(self)
-        sublist.insert(0,
-            make_objecttreeitem("__class__ =", self.object.__class__))
-        return sublist
-
 class ClassTreeItem(ObjectTreeItem):
     def IsExpandable(self):
         return True
@@ -120,7 +111,6 @@ dispatch = {
     TupleType: SequenceTreeItem,
     ListType: SequenceTreeItem,
     DictType: DictTreeItem,
-    InstanceType: InstanceTreeItem,
     ClassType: ClassTreeItem,
 }
 
index 169bcebcc57a25409f6abb569dd61e6225391db5..57a975a510ae757823379aeb5ce1aa20b73cc570 100644 (file)
@@ -574,8 +574,6 @@ def _getmethods(obj, methods):
         attr = getattr(obj, name)
         if callable(attr):
             methods[name] = 1
-    if type(obj) == types.InstanceType:
-        _getmethods(obj.__class__, methods)
     if type(obj) == types.ClassType:
         for super in obj.__bases__:
             _getmethods(super, methods)
index 14e48d683a96ddd1e49bb2868ae4a4a9eba81967..9dfb39fed3a25853b3e87a7d7b986e6dbe96263b 100644 (file)
@@ -518,8 +518,7 @@ class ComponentItem(SelectableItem):
             ss = repr(seld)
         elif IsRange(seld):
             start, stop = seld.start, seld.stop
-            if type(start) == InstanceType == type(stop) and \
-               start.__class__ == self.__class__ == stop.__class__:
+            if type(start) == type(stop) == type(self):
                 ss = str(start.seld) + " thru " + str(stop.seld)
             else:
                 ss = str(seld)
index 282cc27975fbe9698d04dbd56d4002ca2e22307c..6c124193d1fd69b30af61ed57f9ff0b237fde194 100644 (file)
@@ -484,8 +484,8 @@ def windowposition(folder, pos=None):
     openwindow(fsr)
     if not pos:
         return _getwindowposition(folder_alias)
-    if type(pos) == InstanceType:
-        # pos might be a QDPoint object as returned by _getwindowposition
+    if aetypes.IsQDPoint(pos):
+        # QDPoint object as returned by _getwindowposition
         pos = (pos.h, pos.v)
     return _setwindowposition(folder_alias, pos)
 
index a74b97b4d099fd5ce3d5549f3f012ecf4dad5416..9fca8c268b22e9612eeb9f89dacc14d380d1ec39 100755 (executable)
@@ -1433,8 +1433,6 @@ def describe(thing):
         return 'function ' + thing.__name__
     if inspect.ismethod(thing):
         return 'method ' + thing.__name__
-    if type(thing) is types.InstanceType:
-        return 'instance of ' + thing.__class__.__name__
     return type(thing).__name__
 
 def locate(path, forceload=0):
diff --git a/Lib/test/crashers/infinite_rec_5.py b/Lib/test/crashers/infinite_rec_5.py
deleted file mode 100644 (file)
index 18d2963..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-
-# http://python.org/sf/1267884
-
-import types
-
-class C:
-    __str__ = types.InstanceType.__str__
-
-if __name__ == '__main__':
-    str(C())   # segfault: infinite recursion in C
index cc2b5fd57c943cf58f6c496d46d5c0d5a5ea59e9..366ced7c33c5652c579a210576006b127a281053 100644 (file)
@@ -15,7 +15,6 @@ class TestIsInstanceExceptions(unittest.TestCase):
     # (leading to an "undetected error" in the debug build).  Set up is,
     # isinstance(inst, cls) where:
     #
-    # - inst isn't an InstanceType
     # - cls isn't a ClassType, a TypeType, or a TupleType
     # - cls has a __bases__ attribute
     # - inst has a __class__ attribute