[Python-checkins] python/dist/src/Lib pprint.py,1.24,1.25

loewis@users.sourceforge.net loewis@users.sourceforge.net
Sat, 07 Jun 2003 13:17:13 -0700


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

Modified Files:
	pprint.py 
Log Message:
Patch #750542: Use issubclass instead of type identity.


Index: pprint.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pprint.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** pprint.py	31 Dec 2002 07:14:18 -0000	1.24
--- pprint.py	7 Jun 2003 20:17:11 -0000	1.25
***************
*** 131,135 ****
  
          if sepLines:
!             if typ is dict:
                  write('{')
                  if self._indent_per_level > 1:
--- 131,135 ----
  
          if sepLines:
!             if issubclass(typ, dict):
                  write('{')
                  if self._indent_per_level > 1:
***************
*** 158,163 ****
                  return
  
!             if typ is list or typ is tuple:
!                 if typ is list:
                      write('[')
                      endchar = ']'
--- 158,163 ----
                  return
  
!             if issubclass(typ, list) or issubclass(typ, tuple):
!                 if issubclass(typ, list):
                      write('[')
                      endchar = ']'
***************
*** 180,184 ****
                      indent = indent - self._indent_per_level
                      del context[objid]
!                 if typ is tuple and length == 1:
                      write(',')
                  write(endchar)
--- 180,184 ----
                      indent = indent - self._indent_per_level
                      del context[objid]
!                 if issubclass(typ, tuple) and length == 1:
                      write(',')
                  write(endchar)
***************
*** 208,212 ****
  def _safe_repr(object, context, maxlevels, level):
      typ = _type(object)
!     if typ is str:
          if 'locale' not in _sys.modules:
              return `object`, True, False
--- 208,212 ----
  def _safe_repr(object, context, maxlevels, level):
      typ = _type(object)
!     if issubclass(typ, basestring):
          if 'locale' not in _sys.modules:
              return `object`, True, False
***************
*** 227,231 ****
          return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False
  
!     if typ is dict:
          if not object:
              return "{}", True, False
--- 227,231 ----
          return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False
  
!     if issubclass(typ, dict):
          if not object:
              return "{}", True, False
***************
*** 252,257 ****
          return "{%s}" % _commajoin(components), readable, recursive
  
!     if typ is list or typ is tuple:
!         if typ is list:
              if not object:
                  return "[]", True, False
--- 252,257 ----
          return "{%s}" % _commajoin(components), readable, recursive
  
!     if issubclass(typ, list) or issubclass(typ, tuple):
!         if issubclass(typ, list):
              if not object:
                  return "[]", True, False