Merged revisions 77310-77311 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77310 | antoine.pitrou | 2010-01-05 01:22:44 +0200 (Tue, 05 Jan 2010) | 4 lines

  Issue #7092: Fix the DeprecationWarnings emitted by the standard library
  when using the -3 flag.  Patch by Florent Xicluna.
........
  r77311 | antoine.pitrou | 2010-01-05 01:28:16 +0200 (Tue, 05 Jan 2010) | 3 lines

  Kill a couple of "<>"
........
diff --git a/Lib/pprint.py b/Lib/pprint.py
index c48465b..910283e 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -35,6 +35,7 @@
 """
 
 import sys as _sys
+import warnings
 
 from cStringIO import StringIO as _StringIO
 
@@ -70,6 +71,13 @@
     """Determine if object requires a recursive representation."""
     return _safe_repr(object, {}, None, 0)[2]
 
+def _sorted(iterable):
+    with warnings.catch_warnings():
+        if _sys.py3kwarning:
+            warnings.filterwarnings("ignore", "comparing unequal types "
+                                    "not supported", DeprecationWarning)
+        return sorted(iterable)
+
 class PrettyPrinter:
     def __init__(self, indent=1, width=80, depth=None, stream=None):
         """Handle pretty printing operations onto a stream using a set of
@@ -144,8 +152,7 @@
             if length:
                 context[objid] = 1
                 indent = indent + self._indent_per_level
-                items  = object.items()
-                items.sort()
+                items = _sorted(object.items())
                 key, ent = items[0]
                 rep = self._repr(key, context, level)
                 write(rep)
@@ -181,7 +188,7 @@
                     return
                 write('set([')
                 endchar = '])'
-                object = sorted(object)
+                object = _sorted(object)
                 indent += 4
             elif issubclass(typ, frozenset):
                 if not length:
@@ -189,7 +196,7 @@
                     return
                 write('frozenset([')
                 endchar = '])'
-                object = sorted(object)
+                object = _sorted(object)
                 indent += 10
             else:
                 write('(')
@@ -274,7 +281,7 @@
         append = components.append
         level += 1
         saferepr = _safe_repr
-        for k, v in sorted(object.items()):
+        for k, v in _sorted(object.items()):
             krepr, kreadable, krecur = saferepr(k, context, maxlevels, level)
             vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level)
             append("%s: %s" % (krepr, vrepr))