[Python-3000-checkins] r54761 - in python/branches/p3yk/Lib: cgitb.py idlelib/ObjectBrowser.py idlelib/rpc.py plat-mac/aetypes.py plat-mac/findertools.py pydoc.py test/crashers/infinite_rec_5.py test/test_isinstance.py

georg.brandl python-3000-checkins at python.org
Wed Apr 11 21:24:59 CEST 2007


Author: georg.brandl
Date: Wed Apr 11 21:24:50 2007
New Revision: 54761

Removed:
   python/branches/p3yk/Lib/test/crashers/infinite_rec_5.py
Modified:
   python/branches/p3yk/Lib/cgitb.py
   python/branches/p3yk/Lib/idlelib/ObjectBrowser.py
   python/branches/p3yk/Lib/idlelib/rpc.py
   python/branches/p3yk/Lib/plat-mac/aetypes.py
   python/branches/p3yk/Lib/plat-mac/findertools.py
   python/branches/p3yk/Lib/pydoc.py
   python/branches/p3yk/Lib/test/test_isinstance.py
Log:
Bug #1697782: remove all remaining code that uses types.InstanceType.


Modified: python/branches/p3yk/Lib/cgitb.py
==============================================================================
--- python/branches/p3yk/Lib/cgitb.py	(original)
+++ python/branches/p3yk/Lib/cgitb.py	Wed Apr 11 21:24:50 2007
@@ -167,11 +167,10 @@
 
     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 @@
         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) + '''

Modified: python/branches/p3yk/Lib/idlelib/ObjectBrowser.py
==============================================================================
--- python/branches/p3yk/Lib/idlelib/ObjectBrowser.py	(original)
+++ python/branches/p3yk/Lib/idlelib/ObjectBrowser.py	Wed Apr 11 21:24:50 2007
@@ -57,15 +57,6 @@
             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 @@
     TupleType: SequenceTreeItem,
     ListType: SequenceTreeItem,
     DictType: DictTreeItem,
-    InstanceType: InstanceTreeItem,
     ClassType: ClassTreeItem,
 }
 

Modified: python/branches/p3yk/Lib/idlelib/rpc.py
==============================================================================
--- python/branches/p3yk/Lib/idlelib/rpc.py	(original)
+++ python/branches/p3yk/Lib/idlelib/rpc.py	Wed Apr 11 21:24:50 2007
@@ -574,8 +574,6 @@
         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)

Modified: python/branches/p3yk/Lib/plat-mac/aetypes.py
==============================================================================
--- python/branches/p3yk/Lib/plat-mac/aetypes.py	(original)
+++ python/branches/p3yk/Lib/plat-mac/aetypes.py	Wed Apr 11 21:24:50 2007
@@ -518,8 +518,7 @@
             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)

Modified: python/branches/p3yk/Lib/plat-mac/findertools.py
==============================================================================
--- python/branches/p3yk/Lib/plat-mac/findertools.py	(original)
+++ python/branches/p3yk/Lib/plat-mac/findertools.py	Wed Apr 11 21:24:50 2007
@@ -484,8 +484,8 @@
     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)
 

Modified: python/branches/p3yk/Lib/pydoc.py
==============================================================================
--- python/branches/p3yk/Lib/pydoc.py	(original)
+++ python/branches/p3yk/Lib/pydoc.py	Wed Apr 11 21:24:50 2007
@@ -1433,8 +1433,6 @@
         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):

Deleted: /python/branches/p3yk/Lib/test/crashers/infinite_rec_5.py
==============================================================================
--- /python/branches/p3yk/Lib/test/crashers/infinite_rec_5.py	Wed Apr 11 21:24:50 2007
+++ (empty file)
@@ -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

Modified: python/branches/p3yk/Lib/test/test_isinstance.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_isinstance.py	(original)
+++ python/branches/p3yk/Lib/test/test_isinstance.py	Wed Apr 11 21:24:50 2007
@@ -15,7 +15,6 @@
     # (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


More information about the Python-3000-checkins mailing list