summaryrefslogtreecommitdiffstats
path: root/Doc/c-api
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-01-21 11:20:28 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-01-21 11:20:28 (GMT)
commite1c981161c49ce6bc232b62f85ca222530491dae (patch)
tree2e092c9be8b0cd874ce26022e3f58aae64c04f07 /Doc/c-api
parent9bd667ad030913ead3a789f45e73c26f9f28fb46 (diff)
downloadcpython-e1c981161c49ce6bc232b62f85ca222530491dae.zip
cpython-e1c981161c49ce6bc232b62f85ca222530491dae.tar.gz
cpython-e1c981161c49ce6bc232b62f85ca222530491dae.tar.bz2
Merged revisions 60143-60149 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r60143 | georg.brandl | 2008-01-20 15:50:05 +0100 (Sun, 20 Jan 2008) | 3 lines Switch mmap from old Py_FindMethod to new PyObject_GenericGetAttr attribute access. Fixes #1087735. ........ r60145 | georg.brandl | 2008-01-20 20:40:58 +0100 (Sun, 20 Jan 2008) | 2 lines Add blurb about executable scripts on Windows. #760657. ........ r60146 | georg.brandl | 2008-01-20 20:48:40 +0100 (Sun, 20 Jan 2008) | 2 lines #1219903: fix tp_richcompare docs. ........ r60147 | georg.brandl | 2008-01-20 22:10:08 +0100 (Sun, 20 Jan 2008) | 2 lines Fix markup. ........ r60148 | gregory.p.smith | 2008-01-21 08:11:11 +0100 (Mon, 21 Jan 2008) | 14 lines Provide a sanity check during PyThreadState_DeleteCurrent() and PyThreadState_Delete() to avoid an infinite loop when the tstate list is messed up and has somehow becomes circular and does not contain the current thread. I don't know how this happens but it does, *very* rarely. On more than one hardware platform. I have not been able to reproduce it manually. Attaching to a process where its happening: it has always been in an infinite loop over a single element tstate list that is not the tstate we're looking to delete. It has been in t_bootstrap()'s call to PyThreadState_DeleteCurrent() as a pthread is exiting. ........ r60149 | georg.brandl | 2008-01-21 11:24:59 +0100 (Mon, 21 Jan 2008) | 2 lines #1269: fix a bug in pstats.add_callers() and add a unit test file for pstats. ........
Diffstat (limited to 'Doc/c-api')
-rw-r--r--Doc/c-api/typeobj.rst20
1 files changed, 13 insertions, 7 deletions
diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst
index b3433e1..f1a8233 100644
--- a/Doc/c-api/typeobj.rst
+++ b/Doc/c-api/typeobj.rst
@@ -649,13 +649,19 @@ The following three fields only exist if the
.. cmember:: richcmpfunc PyTypeObject.tp_richcompare
- An optional pointer to the rich comparison function.
+ An optional pointer to the rich comparison function, whose signature is
+ ``PyObject *tp_richcompare(PyObject *a, PyObject *b, int op)``.
- The signature is the same as for :cfunc:`PyObject_RichCompare`. The function
- should return the result of the comparison (usually ``Py_True`` or
- ``Py_False``). If the comparison is undefined, it must return
- ``Py_NotImplemented``, if another error occurred it must return ``NULL`` and set
- an exception condition.
+ The function should return the result of the comparison (usually ``Py_True``
+ or ``Py_False``). If the comparison is undefined, it must return
+ ``Py_NotImplemented``, if another error occurred it must return ``NULL`` and
+ set an exception condition.
+
+ .. note::
+
+ If you want to implement a type for which only a limited set of
+ 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`,
@@ -681,10 +687,10 @@ The following three fields only exist if the
| :const:`Py_GE` | ``>=`` |
+----------------+------------+
+
The next field only exists if the :const:`Py_TPFLAGS_HAVE_WEAKREFS` flag bit is
set.
-
.. cmember:: long PyTypeObject.tp_weaklistoffset
If the instances of this type are weakly referenceable, this field is greater