[Python-checkins] r69224 - in python/branches/py3k: 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
mark.dickinson
python-checkins at python.org
Mon Feb 2 22:29:40 CET 2009
Author: mark.dickinson
Date: Mon Feb 2 22:29:40 2009
New Revision: 69224
Log:
Issue #1717, continued: Doc fixes and other cleanup related
to renaming of tp_compare.
Modified:
python/branches/py3k/Doc/c-api/typeobj.rst
python/branches/py3k/Doc/extending/newtypes.rst
python/branches/py3k/Doc/includes/noddy.c
python/branches/py3k/Doc/includes/noddy2.c
python/branches/py3k/Doc/includes/noddy3.c
python/branches/py3k/Doc/includes/noddy4.c
python/branches/py3k/Doc/includes/shoddy.c
python/branches/py3k/Doc/includes/typestruct.h
python/branches/py3k/Tools/framer/framer/slots.py
Modified: python/branches/py3k/Doc/c-api/typeobj.rst
==============================================================================
--- python/branches/py3k/Doc/c-api/typeobj.rst (original)
+++ python/branches/py3k/Doc/c-api/typeobj.rst Mon Feb 2 22:29:40 2009
@@ -23,7 +23,7 @@
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 @@
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 @@
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.
-
- 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*.
+ 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`: 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 @@
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`:
Modified: python/branches/py3k/Doc/extending/newtypes.rst
==============================================================================
--- python/branches/py3k/Doc/extending/newtypes.rst (original)
+++ python/branches/py3k/Doc/extending/newtypes.rst Mon Feb 2 22:29:40 2009
@@ -80,7 +80,7 @@
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 @@
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
Modified: python/branches/py3k/Doc/includes/noddy.c
==============================================================================
--- python/branches/py3k/Doc/includes/noddy.c (original)
+++ python/branches/py3k/Doc/includes/noddy.c Mon Feb 2 22:29:40 2009
@@ -14,7 +14,7 @@
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 */
Modified: python/branches/py3k/Doc/includes/noddy2.c
==============================================================================
--- python/branches/py3k/Doc/includes/noddy2.c (original)
+++ python/branches/py3k/Doc/includes/noddy2.c Mon Feb 2 22:29:40 2009
@@ -131,7 +131,7 @@
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 */
Modified: python/branches/py3k/Doc/includes/noddy3.c
==============================================================================
--- python/branches/py3k/Doc/includes/noddy3.c (original)
+++ python/branches/py3k/Doc/includes/noddy3.c Mon Feb 2 22:29:40 2009
@@ -184,7 +184,7 @@
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 */
Modified: python/branches/py3k/Doc/includes/noddy4.c
==============================================================================
--- python/branches/py3k/Doc/includes/noddy4.c (original)
+++ python/branches/py3k/Doc/includes/noddy4.c Mon Feb 2 22:29:40 2009
@@ -165,7 +165,7 @@
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 */
Modified: python/branches/py3k/Doc/includes/shoddy.c
==============================================================================
--- python/branches/py3k/Doc/includes/shoddy.c (original)
+++ python/branches/py3k/Doc/includes/shoddy.c Mon Feb 2 22:29:40 2009
@@ -39,7 +39,7 @@
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 */
Modified: python/branches/py3k/Doc/includes/typestruct.h
==============================================================================
--- python/branches/py3k/Doc/includes/typestruct.h (original)
+++ python/branches/py3k/Doc/includes/typestruct.h Mon Feb 2 22:29:40 2009
@@ -9,7 +9,7 @@
printfunc tp_print;
getattrfunc tp_getattr;
setattrfunc tp_setattr;
- cmpfunc tp_compare;
+ void *tp_reserved;
reprfunc tp_repr;
/* Method suites for standard classes */
Modified: python/branches/py3k/Tools/framer/framer/slots.py
==============================================================================
--- python/branches/py3k/Tools/framer/framer/slots.py (original)
+++ python/branches/py3k/Tools/framer/framer/slots.py Mon Feb 2 22:29:40 2009
@@ -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