[Python-checkins] CVS: python/dist/src/Lib pydoc.py,1.52,1.53

Tim Peters tim_one@users.sourceforge.net
Wed, 26 Sep 2001 20:29:53 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv23454/python/Lib

Modified Files:
	pydoc.py 
Log Message:
List class attrs in MRO order of defining class instead of by alphabetic
order of defining class's name.


Index: pydoc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** pydoc.py	2001/09/26 22:39:22	1.52
--- pydoc.py	2001/09/27 03:29:51	1.53
***************
*** 622,626 ****
  
          # List the mro, if non-trivial.
!         mro = inspect.getmro(object)
          if len(mro) > 2:
              hr.maybe()
--- 622,626 ----
  
          # List the mro, if non-trivial.
!         mro = list(inspect.getmro(object))
          if len(mro) > 2:
              hr.maybe()
***************
*** 694,702 ****
                  pass
  
-         # Sort attrs by name of defining class.
-         attrs.sort(lambda t1, t2: cmp(t1[2].__name__, t2[2].__name__))
- 
-         thisclass = object  # list attrs defined here first
          while attrs:
              attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
  
--- 694,702 ----
                  pass
  
          while attrs:
+             if mro:
+                 thisclass = mro.pop(0)
+             else:
+                 thisclass = attrs[0][2]
              attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
  
***************
*** 723,732 ****
                                lambda t: t[1] == 'data')
              assert attrs == []
! 
!             # Split off the attributes inherited from the next class (note
!             # that inherited remains sorted by class name).
!             if inherited:
!                 attrs = inherited
!                 thisclass = attrs[0][2]
  
          contents = ''.join(contents)
--- 723,727 ----
                                lambda t: t[1] == 'data')
              assert attrs == []
!             attrs = inherited
  
          contents = ''.join(contents)
***************
*** 1009,1013 ****
  
          # List the mro, if non-trivial.
!         mro = inspect.getmro(object)
          if len(mro) > 2:
              push("Method resolution order:")
--- 1004,1008 ----
  
          # List the mro, if non-trivial.
!         mro = list(inspect.getmro(object))
          if len(mro) > 2:
              push("Method resolution order:")
***************
*** 1073,1082 ****
  
          attrs = inspect.classify_class_attrs(object)
- 
-         # Sort attrs by name of defining class.
-         attrs.sort(lambda t1, t2: cmp(t1[2].__name__, t2[2].__name__))
- 
-         thisclass = object  # list attrs defined here first
          while attrs:
              attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
  
--- 1068,1076 ----
  
          attrs = inspect.classify_class_attrs(object)
          while attrs:
+             if mro:
+                 thisclass = mro.pop(0)
+             else:
+                 thisclass = attrs[0][2]
              attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
  
***************
*** 1102,1111 ****
                                attrs, lambda t: t[1] == 'data')
              assert attrs == []
! 
!             # Split off the attributes inherited from the next class (note
!             # that inherited remains sorted by class name).
!             if inherited:
!                 attrs = inherited
!                 thisclass = attrs[0][2]
  
          contents = '\n'.join(contents)
--- 1096,1100 ----
                                attrs, lambda t: t[1] == 'data')
              assert attrs == []
!             attrs = inherited
  
          contents = '\n'.join(contents)