]> granicus.if.org Git - python/commitdiff
Issue #1717, continued: Doc fixes and other cleanup related
authorMark Dickinson <dickinsm@gmail.com>
Mon, 2 Feb 2009 21:29:40 +0000 (21:29 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Mon, 2 Feb 2009 21:29:40 +0000 (21:29 +0000)
to renaming of tp_compare.

Doc/c-api/typeobj.rst
Doc/extending/newtypes.rst
Doc/includes/noddy.c
Doc/includes/noddy2.c
Doc/includes/noddy3.c
Doc/includes/noddy4.c
Doc/includes/shoddy.c
Doc/includes/typestruct.h
Tools/framer/framer/slots.py

index 6d98d6b86454397d5c50f895be8daa3f72dc252f..7dd576e7bbaec58f03837bfc8744efbca69b6a42 100644 (file)
@@ -23,7 +23,7 @@ structure.
 Typedefs: unaryfunc, binaryfunc, ternaryfunc, inquiry, intargfunc,
 intintargfunc, intobjargproc, intintobjargproc, objobjargproc, destructor,
 freefunc, printfunc, getattrfunc, getattrofunc, setattrfunc, setattrofunc,
-cmpfunc, reprfunc, hashfunc
+reprfunc, hashfunc
 
 The structure definition for :ctype:`PyTypeObject` can be found in
 :file:`Include/object.h`.  For convenience of reference, this repeats the
@@ -244,19 +244,9 @@ type objects) *must* have the :attr:`ob_size` field.
    the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*.
 
 
-.. cmember:: cmpfunc PyTypeObject.tp_compare
+.. cmember:: void* PyTypeObject.tp_reserved
 
-   An optional pointer to the three-way comparison function.
-
-   The signature is the same as for :cfunc:`PyObject_Compare`. The function should
-   return ``1`` if *self* greater than *other*, ``0`` if *self* is equal to
-   *other*, and ``-1`` if *self* less than *other*.  It should return ``-1`` and
-   set an exception condition when an error occurred during the comparison.
-
-   This field is inherited by subtypes together with :attr:`tp_richcompare` and
-   :attr:`tp_hash`: a subtypes inherits all three of :attr:`tp_compare`,
-   :attr:`tp_richcompare`, and :attr:`tp_hash` when the subtype's
-   :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*.
+   Reserved slot, formerly known as tp_compare.
 
 
 .. cmember:: reprfunc PyTypeObject.tp_repr
@@ -329,14 +319,13 @@ type objects) *must* have the :attr:`ob_size` field.
    the Python level will result in the ``tp_hash`` slot being set to
    :cfunc:`PyObject_HashNotImplemented`.
 
-   When this field is not set, two possibilities exist: if the :attr:`tp_compare`
-   and :attr:`tp_richcompare` fields are both *NULL*, a default hash value based on
-   the object's address is returned; otherwise, a :exc:`TypeError` is raised.
+   When this field is not set, an attempt to take the hash of the
+   object raises :exc:`TypeError`.
 
-   This field is inherited by subtypes together with :attr:`tp_richcompare` and
-   :attr:`tp_compare`: a subtypes inherits all three of :attr:`tp_compare`,
-   :attr:`tp_richcompare`, and :attr:`tp_hash`, when the subtype's
-   :attr:`tp_compare`, :attr:`tp_richcompare` and :attr:`tp_hash` are all *NULL*.
+   This field is inherited by subtypes together with
+   :attr:`tp_richcompare`: a subtype inherits both of
+   :attr:`tp_richcompare` and :attr:`tp_hash`, when the subtype's
+   :attr:`tp_richcompare` and :attr:`tp_hash` are both *NULL*.
 
 
 .. cmember:: ternaryfunc PyTypeObject.tp_call
@@ -596,10 +585,10 @@ type objects) *must* have the :attr:`ob_size` field.
       comparisons makes sense (e.g. ``==`` and ``!=``, but not ``<`` and
       friends), directly raise :exc:`TypeError` in the rich comparison function.
 
-   This field is inherited by subtypes together with :attr:`tp_compare` and
-   :attr:`tp_hash`: a subtype inherits all three of :attr:`tp_compare`,
-   :attr:`tp_richcompare`, and :attr:`tp_hash`, when the subtype's
-   :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*.
+   This field is inherited by subtypes together with :attr:`tp_hash`:
+   a subtype inherits :attr:`tp_richcompare` and :attr:`tp_hash` when
+   the subtype's :attr:`tp_richcompare` and :attr:`tp_hash` are both
+   *NULL*.
 
    The following constants are defined to be used as the third argument for
    :attr:`tp_richcompare` and for :cfunc:`PyObject_RichCompare`:
index 1484c7997fea8167539c741ceb45858b19f77c85..a0a797a5050efb639d04a106eebe08e42097a4e6 100644 (file)
@@ -80,7 +80,7 @@ Moving on, we come to the crunch --- the type object. ::
        0,                         /* tp_print */
        0,                         /* tp_getattr */
        0,                         /* tp_setattr */
-       0,                         /* tp_compare */
+       0,                         /* tp_reserved */
        0,                         /* tp_repr */
        0,                         /* tp_as_number */
        0,                         /* tp_as_sequence */
@@ -1484,10 +1484,10 @@ provide.  They are in :file:`object.h` in the Python include directory that
 comes with the source distribution of Python.
 
 In order to learn how to implement any specific method for your new data type,
-do the following: Download and unpack the Python source distribution.  Go the
-:file:`Objects` directory, then search the C source files for ``tp_`` plus the
-function you want (for example, ``tp_compare``).  You will find examples of the
-function you want to implement.
+do the following: Download and unpack the Python source distribution.  Go to
+the :file:`Objects` directory, then search the C source files for ``tp_`` plus
+the function you want (for example, ``tp_richcompare``).  You will find examples
+of the function you want to implement.
 
 When you need to verify that an object is an instance of the type you are
 implementing, use the :cfunc:`PyObject_TypeCheck` function. A sample of its use
index b6b7d6feda339d8b3dd4365e542812fcac22164e..3f37434e3050e46cc7309689c9578f3330f2f528 100644 (file)
@@ -14,7 +14,7 @@ static PyTypeObject noddy_NoddyType = {
     0,                         /* tp_print */
     0,                         /* tp_getattr */
     0,                         /* tp_setattr */
-    0,                         /* tp_compare */
+    0,                         /* tp_reserved */
     0,                         /* tp_repr */
     0,                         /* tp_as_number */
     0,                         /* tp_as_sequence */
index db9c7a88d524bd9fda5d127d3d89023c1f4ee544..0907281baa731d6249f4539f42d5964ac24b5f46 100644 (file)
@@ -131,7 +131,7 @@ static PyTypeObject NoddyType = {
     0,                         /* tp_print */
     0,                         /* tp_getattr */
     0,                         /* tp_setattr */
-    0,                         /* tp_compare */
+    0,                         /* tp_reserved */
     0,                         /* tp_repr */
     0,                         /* tp_as_number */
     0,                         /* tp_as_sequence */
index e98b87fdd3953a82ff713c85e2f747a9f30056c0..fac44d880862f4662a05ad3eb2a60f8f0ae057cc 100644 (file)
@@ -184,7 +184,7 @@ static PyTypeObject NoddyType = {
     0,                         /* tp_print */
     0,                         /* tp_getattr */
     0,                         /* tp_setattr */
-    0,                         /* tp_compare */
+    0,                         /* tp_reserved */
     0,                         /* tp_repr */
     0,                         /* tp_as_number */
     0,                         /* tp_as_sequence */
index 5be00a796a96b0f3dc9b4cf8d4401976a1bdeadd..1b3704ceff8dfde9bc1b905727c7d3524e88899d 100644 (file)
@@ -165,7 +165,7 @@ static PyTypeObject NoddyType = {
     0,                         /* tp_print */
     0,                         /* tp_getattr */
     0,                         /* tp_setattr */
-    0,                         /* tp_compare */
+    0,                         /* tp_reserved */
     0,                         /* tp_repr */
     0,                         /* tp_as_number */
     0,                         /* tp_as_sequence */
index 3757bca0ef879b7773d5c46a736d06739e928e3a..bb7f05b107cdd1b37a0ec5d9776042e5417271f5 100644 (file)
@@ -39,7 +39,7 @@ static PyTypeObject ShoddyType = {
     0,                       /* tp_print */
     0,                       /* tp_getattr */
     0,                       /* tp_setattr */
-    0,                       /* tp_compare */
+    0,                       /* tp_reserved */
     0,                       /* tp_repr */
     0,                       /* tp_as_number */
     0,                       /* tp_as_sequence */
index f6451b925db5271a2ad5317c12492c39fe8f61ce..32647c0ee514e0f07e7245db5d71fe074f21df4b 100644 (file)
@@ -9,7 +9,7 @@ typedef struct _typeobject {
     printfunc tp_print;
     getattrfunc tp_getattr;
     setattrfunc tp_setattr;
-    cmpfunc tp_compare;
+    void *tp_reserved;
     reprfunc tp_repr;
 
     /* Method suites for standard classes */
index d369c9ad0501fe6e57db248bd6d32f0c2b8f777f..0f6e6fe229754bb201a1b3cc6f2939907a2dac04 100644 (file)
@@ -15,7 +15,7 @@ Slots = (Slot("ob_size"),
          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"),