summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2014-01-05 14:50:30 (GMT)
committerEthan Furman <ethan@stoneleaf.us>2014-01-05 14:50:30 (GMT)
commitdf3ed242c07ac9d0d46faa89a4705bd6acb3dd68 (patch)
tree87d790e70c68ff68f865a37a0ecd6720580a089d /Doc
parent6d2ea213372bf585e797777824c6ed2209dc22c0 (diff)
downloadcpython-df3ed242c07ac9d0d46faa89a4705bd6acb3dd68.zip
cpython-df3ed242c07ac9d0d46faa89a4705bd6acb3dd68.tar.gz
cpython-df3ed242c07ac9d0d46faa89a4705bd6acb3dd68.tar.bz2
Issue19995: %o, %x, %X now only accept ints
Diffstat (limited to 'Doc')
-rw-r--r--Doc/reference/datamodel.rst14
1 files changed, 11 insertions, 3 deletions
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 26d93a6..4f19b37 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -2080,9 +2080,17 @@ left undefined.
.. method:: object.__index__(self)
- Called to implement :func:`operator.index`. Also called whenever Python needs
- an integer object (such as in slicing, or in the built-in :func:`bin`,
- :func:`hex` and :func:`oct` functions). Must return an integer.
+ Called to implement :func:`operator.index`, and whenever Python needs to
+ losslessly convert the numeric object to an integer object (such as in
+ slicing, or in the built-in :func:`bin`, :func:`hex` and :func:`oct`
+ functions). Presence of this method indicates that the numeric object is
+ an integer type. Must return an integer.
+
+ .. note::
+
+ When :meth:`__index__` is defined, :meth:`__int__` should also be defined,
+ and both shuld return the same value, in order to have a coherent integer
+ type class.
.. _context-managers: