[Python-checkins] r67670 - in python/branches/py3k-issue1717: Include/code.h Lib/locale.py Lib/pydoc.py Lib/test/test_dict.py Lib/test/test_hmac.py Lib/xml/dom/minidom.py Lib/xml/etree/ElementTree.py Lib/xmlrpc/client.py Tools/framer/framer/slots.py

mark.dickinson python-checkins at python.org
Mon Dec 8 22:24:19 CET 2008


Author: mark.dickinson
Date: Mon Dec  8 22:24:18 2008
New Revision: 67670

Log:
More cmp fixes, mostly to the library


Modified:
   python/branches/py3k-issue1717/Include/code.h
   python/branches/py3k-issue1717/Lib/locale.py
   python/branches/py3k-issue1717/Lib/pydoc.py
   python/branches/py3k-issue1717/Lib/test/test_dict.py
   python/branches/py3k-issue1717/Lib/test/test_hmac.py
   python/branches/py3k-issue1717/Lib/xml/dom/minidom.py
   python/branches/py3k-issue1717/Lib/xml/etree/ElementTree.py
   python/branches/py3k-issue1717/Lib/xmlrpc/client.py
   python/branches/py3k-issue1717/Tools/framer/framer/slots.py

Modified: python/branches/py3k-issue1717/Include/code.h
==============================================================================
--- python/branches/py3k-issue1717/Include/code.h	(original)
+++ python/branches/py3k-issue1717/Include/code.h	Mon Dec  8 22:24:18 2008
@@ -20,7 +20,7 @@
     PyObject *co_varnames;	/* tuple of strings (local variable names) */
     PyObject *co_freevars;	/* tuple of strings (free variable names) */
     PyObject *co_cellvars;      /* tuple of strings (cell variable names) */
-    /* The rest doesn't count for hash/cmp */
+    /* The rest doesn't count for hash */
     PyObject *co_filename;	/* unicode (where it was loaded from) */
     PyObject *co_name;		/* unicode (name, for reference) */
     int co_firstlineno;		/* first source line number */

Modified: python/branches/py3k-issue1717/Lib/locale.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/locale.py	(original)
+++ python/branches/py3k-issue1717/Lib/locale.py	Mon Dec  8 22:24:18 2008
@@ -31,7 +31,7 @@
     """ strcoll(string,string) -> int.
         Compares two strings according to the locale.
     """
-    return cmp(a,b)
+    return (a > b) - (a < b)
 
 def _strxfrm(s):
     """ strxfrm(string) -> string.

Modified: python/branches/py3k-issue1717/Lib/pydoc.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/pydoc.py	(original)
+++ python/branches/py3k-issue1717/Lib/pydoc.py	Mon Dec  8 22:24:18 2008
@@ -1607,7 +1607,7 @@
         'SPECIALMETHODS': ('specialnames', 'BASICMETHODS ATTRIBUTEMETHODS '
                            'CALLABLEMETHODS SEQUENCEMETHODS1 MAPPINGMETHODS '
                            'SEQUENCEMETHODS2 NUMBERMETHODS CLASSES'),
-        'BASICMETHODS': ('customization', 'cmp hash repr str SPECIALMETHODS'),
+        'BASICMETHODS': ('customization', 'hash repr str SPECIALMETHODS'),
         'ATTRIBUTEMETHODS': ('attribute-access', 'ATTRIBUTES SPECIALMETHODS'),
         'CALLABLEMETHODS': ('callable-types', 'CALLS SPECIALMETHODS'),
         'SEQUENCEMETHODS': ('sequence-types', 'SEQUENCES SEQUENCEMETHODS2 '

Modified: python/branches/py3k-issue1717/Lib/test/test_dict.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_dict.py	(original)
+++ python/branches/py3k-issue1717/Lib/test/test_dict.py	Mon Dec  8 22:24:18 2008
@@ -569,7 +569,7 @@
             self.fail("missing KeyError")
 
     def test_bad_key(self):
-        # Dictionary lookups should fail if __cmp__() raises an exception.
+        # Dictionary lookups should fail if __eq__() raises an exception.
         class CustomException(Exception):
             pass
 

Modified: python/branches/py3k-issue1717/Lib/test/test_hmac.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_hmac.py	(original)
+++ python/branches/py3k-issue1717/Lib/test/test_hmac.py	Mon Dec  8 22:24:18 2008
@@ -291,7 +291,7 @@
         # Testing if the copy method created a real copy.
         h1 = hmac.HMAC(b"key")
         h2 = h1.copy()
-        # Using id() in case somebody has overridden __cmp__.
+        # Using id() in case somebody has overridden __eq__/__ne__.
         self.failUnless(id(h1) != id(h2), "No real copy of the HMAC instance.")
         self.failUnless(id(h1.inner) != id(h2.inner),
             "No real copy of the attribute 'inner'.")

Modified: python/branches/py3k-issue1717/Lib/xml/dom/minidom.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/xml/dom/minidom.py	(original)
+++ python/branches/py3k-issue1717/Lib/xml/dom/minidom.py	Mon Dec  8 22:24:18 2008
@@ -524,7 +524,7 @@
         if self._attrs is getattr(other, "_attrs", None):
             return 0
         else:
-            return cmp(id(self), id(other))
+            return (id(self) > id(other)) - (id(self) < id(other))
 
     def __getitem__(self, attname_or_tuple):
         if isinstance(attname_or_tuple, tuple):

Modified: python/branches/py3k-issue1717/Lib/xml/etree/ElementTree.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/xml/etree/ElementTree.py	(original)
+++ python/branches/py3k-issue1717/Lib/xml/etree/ElementTree.py	Mon Dec  8 22:24:18 2008
@@ -500,8 +500,8 @@
         return hash(self.text)
     def __cmp__(self, other):
         if isinstance(other, QName):
-            return cmp(self.text, other.text)
-        return cmp(self.text, other)
+            return (self.text > other.text) - (self.text < other.text)
+        return (self.text > other) - (self.text < other)
 
 ##
 # ElementTree wrapper class.  This class represents an entire element

Modified: python/branches/py3k-issue1717/Lib/xmlrpc/client.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/xmlrpc/client.py	(original)
+++ python/branches/py3k-issue1717/Lib/xmlrpc/client.py	Mon Dec  8 22:24:18 2008
@@ -351,7 +351,7 @@
 
     def __cmp__(self, other):
         s, o = self.make_comparable(other)
-        return cmp(s, o)
+        return (s > o) - (s < o)
 
     ##
     # Get date/time value.

Modified: python/branches/py3k-issue1717/Tools/framer/framer/slots.py
==============================================================================
--- python/branches/py3k-issue1717/Tools/framer/framer/slots.py	(original)
+++ python/branches/py3k-issue1717/Tools/framer/framer/slots.py	Mon Dec  8 22:24:18 2008
@@ -15,7 +15,7 @@
          Slot("tp_print", "printfunc"),
          Slot("tp_getattr", "getattrfunc"),
          Slot("tp_setattr", "setattrfunc"),
-         Slot("tp_compare", "cmpfunc", "__cmp__"),
+         Slot("tp_reserved", "void*"),
          Slot("tp_repr", "reprfunc", "__repr__"),
          Slot("tp_as_number"),
          Slot("tp_as_sequence"),


More information about the Python-checkins mailing list