Skip to content

Commit 0b68a2d

Browse files
Issue 19195: Improved cross-references in C API documentation.
1 parent 91aaeac commit 0b68a2d

File tree

10 files changed

+35
-33
lines changed

10 files changed

+35
-33
lines changed

Doc/c-api/codec.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ and *NULL* returned.
5252
5353
.. c:function:: PyObject* PyCodec_IncrementalEncoder(const char *encoding, const char *errors)
5454
55-
Get an :class:`IncrementalEncoder` object for the given *encoding*.
55+
Get an :class:`~codecs.IncrementalEncoder` object for the given *encoding*.
5656
5757
.. c:function:: PyObject* PyCodec_IncrementalDecoder(const char *encoding, const char *errors)
5858
59-
Get an :class:`IncrementalDecoder` object for the given *encoding*.
59+
Get an :class:`~codecs.IncrementalDecoder` object for the given *encoding*.
6060
6161
.. c:function:: PyObject* PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors)
6262
63-
Get a :class:`StreamReader` factory function for the given *encoding*.
63+
Get a :class:`~codecs.StreamReader` factory function for the given *encoding*.
6464
6565
.. c:function:: PyObject* PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors)
6666
67-
Get a :class:`StreamWriter` factory function for the given *encoding*.
67+
Get a :class:`~codecs.StreamWriter` factory function for the given *encoding*.
6868
6969
7070
Registry API for Unicode encoding error handlers

Doc/c-api/file.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,18 @@ the :mod:`io` APIs instead.
4040
4141
Return the file descriptor associated with *p* as an :c:type:`int`. If the
4242
object is an integer, its value is returned. If not, the
43-
object's :meth:`fileno` method is called if it exists; the method must return
44-
an integer, which is returned as the file descriptor value. Sets an
45-
exception and returns ``-1`` on failure.
43+
object's :meth:`~io.IOBase.fileno` method is called if it exists; the
44+
method must return an integer, which is returned as the file descriptor
45+
value. Sets an exception and returns ``-1`` on failure.
4646
4747
4848
.. c:function:: PyObject* PyFile_GetLine(PyObject *p, int n)
4949
5050
.. index:: single: EOFError (built-in exception)
5151
5252
Equivalent to ``p.readline([n])``, this function reads one line from the
53-
object *p*. *p* may be a file object or any object with a :meth:`readline`
53+
object *p*. *p* may be a file object or any object with a
54+
:meth:`~io.IOBase.readline`
5455
method. If *n* is ``0``, exactly one line is read, regardless of the length of
5556
the line. If *n* is greater than ``0``, no more than *n* bytes will be read
5657
from the file; a partial line can be returned. In both cases, an empty string

Doc/c-api/object.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ Object Protocol
6060
Generic attribute getter function that is meant to be put into a type
6161
object's ``tp_getattro`` slot. It looks for a descriptor in the dictionary
6262
of classes in the object's MRO as well as an attribute in the object's
63-
:attr:`__dict__` (if present). As outlined in :ref:`descriptors`, data
64-
descriptors take preference over instance attributes, while non-data
63+
:attr:`~object.__dict__` (if present). As outlined in :ref:`descriptors`,
64+
data descriptors take preference over instance attributes, while non-data
6565
descriptors don't. Otherwise, an :exc:`AttributeError` is raised.
6666
6767
@@ -85,8 +85,8 @@ Object Protocol
8585
object's ``tp_setattro`` slot. It looks for a data descriptor in the
8686
dictionary of classes in the object's MRO, and if found it takes preference
8787
over setting the attribute in the instance dictionary. Otherwise, the
88-
attribute is set in the object's :attr:`__dict__` (if present). Otherwise,
89-
an :exc:`AttributeError` is raised and ``-1`` is returned.
88+
attribute is set in the object's :attr:`~object.__dict__` (if present).
89+
Otherwise, an :exc:`AttributeError` is raised and ``-1`` is returned.
9090
9191
9292
.. c:function:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name)
@@ -189,9 +189,9 @@ Object Protocol
189189
be done against every entry in *cls*. The result will be ``1`` when at least one
190190
of the checks returns ``1``, otherwise it will be ``0``. If *inst* is not a
191191
class instance and *cls* is neither a type object, nor a class object, nor a
192-
tuple, *inst* must have a :attr:`__class__` attribute --- the class relationship
193-
of the value of that attribute with *cls* will be used to determine the result
194-
of this function.
192+
tuple, *inst* must have a :attr:`~instance.__class__` attribute --- the
193+
class relationship of the value of that attribute with *cls* will be used
194+
to determine the result of this function.
195195
196196
197197
Subclass determination is done in a fairly straightforward way, but includes a
@@ -201,9 +201,9 @@ of. If :class:`A` and :class:`B` are class objects, :class:`B` is a subclass of
201201
either is not a class object, a more general mechanism is used to determine the
202202
class relationship of the two objects. When testing if *B* is a subclass of
203203
*A*, if *A* is *B*, :c:func:`PyObject_IsSubclass` returns true. If *A* and *B*
204-
are different objects, *B*'s :attr:`__bases__` attribute is searched in a
205-
depth-first fashion for *A* --- the presence of the :attr:`__bases__` attribute
206-
is considered sufficient for this determination.
204+
are different objects, *B*'s :attr:`~class.__bases__` attribute is searched in
205+
a depth-first fashion for *A* --- the presence of the :attr:`~class.__bases__`
206+
attribute is considered sufficient for this determination.
207207
208208
209209
.. c:function:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls)

Doc/c-api/set.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
140140
141141
Return 1 if found and removed, 0 if not found (no action taken), and -1 if an
142142
error is encountered. Does not raise :exc:`KeyError` for missing keys. Raise a
143-
:exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`discard`
143+
:exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~set.discard`
144144
method, this function does not automatically convert unhashable sets into
145145
temporary frozensets. Raise :exc:`PyExc_SystemError` if *set* is an not an
146146
instance of :class:`set` or its subtype.

Doc/c-api/typeobj.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ type objects) *must* have the :attr:`ob_size` field.
502502

503503
On the other hand, even if you know a member can never be part of a cycle, as a
504504
debugging aid you may want to visit it anyway just so the :mod:`gc` module's
505-
:func:`get_referents` function will include it.
505+
:func:`~gc.get_referents` function will include it.
506506

507507
Note that :c:func:`Py_VISIT` requires the *visit* and *arg* parameters to
508508
:c:func:`local_traverse` to have these specific names; don't name them just
@@ -627,7 +627,7 @@ type objects) *must* have the :attr:`ob_size` field.
627627
reference list head than the base type. Since the list head is always found via
628628
:c:member:`~PyTypeObject.tp_weaklistoffset`, this should not be a problem.
629629

630-
When a type defined by a class statement has no :attr:`__slots__` declaration,
630+
When a type defined by a class statement has no :attr:`~object.__slots__` declaration,
631631
and none of its base types are weakly referenceable, the type is made weakly
632632
referenceable by adding a weak reference list head slot to the instance layout
633633
and setting the :c:member:`~PyTypeObject.tp_weaklistoffset` of that slot's offset.
@@ -817,15 +817,15 @@ type objects) *must* have the :attr:`ob_size` field.
817817
dictionary at a difference offset than the base type. Since the dictionary is
818818
always found via :c:member:`~PyTypeObject.tp_dictoffset`, this should not be a problem.
819819

820-
When a type defined by a class statement has no :attr:`__slots__` declaration,
820+
When a type defined by a class statement has no :attr:`~object.__slots__` declaration,
821821
and none of its base types has an instance variable dictionary, a dictionary
822822
slot is added to the instance layout and the :c:member:`~PyTypeObject.tp_dictoffset` is set to
823823
that slot's offset.
824824

825825
When a type defined by a class statement has a :attr:`__slots__` declaration,
826826
the type inherits its :c:member:`~PyTypeObject.tp_dictoffset` from its base type.
827827

828-
(Adding a slot named :attr:`__dict__` to the :attr:`__slots__` declaration does
828+
(Adding a slot named :attr:`~object.__dict__` to the :attr:`__slots__` declaration does
829829
not have the expected effect, it just causes confusion. Maybe this should be
830830
added as a feature just like :attr:`__weakref__` though.)
831831

Doc/c-api/unicode.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ These are the generic codec APIs:
967967
968968
Create a Unicode object by decoding *size* bytes of the encoded string *s*.
969969
*encoding* and *errors* have the same meaning as the parameters of the same name
970-
in the :func:`unicode` built-in function. The codec to be used is looked up
970+
in the :func:`str` built-in function. The codec to be used is looked up
971971
using the Python codec registry. Return *NULL* if an exception was raised by
972972
the codec.
973973
@@ -977,7 +977,7 @@ These are the generic codec APIs:
977977
978978
Encode a Unicode object and return the result as Python bytes object.
979979
*encoding* and *errors* have the same meaning as the parameters of the same
980-
name in the Unicode :meth:`encode` method. The codec to be used is looked up
980+
name in the Unicode :meth:`~str.encode` method. The codec to be used is looked up
981981
using the Python codec registry. Return *NULL* if an exception was raised by
982982
the codec.
983983
@@ -987,7 +987,7 @@ These are the generic codec APIs:
987987
988988
Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* and return a Python
989989
bytes object. *encoding* and *errors* have the same meaning as the
990-
parameters of the same name in the Unicode :meth:`encode` method. The codec
990+
parameters of the same name in the Unicode :meth:`~str.encode` method. The codec
991991
to be used is looked up using the Python codec registry. Return *NULL* if an
992992
exception was raised by the codec.
993993

Doc/c-api/veryhigh.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ the same library that the Python runtime is using.
283283
frame *f* is executed, interpreting bytecode and executing calls as needed.
284284
The additional *throwflag* parameter can mostly be ignored - if true, then
285285
it causes an exception to immediately be thrown; this is used for the
286-
:meth:`throw` methods of generator objects.
286+
:meth:`~generator.throw` methods of generator objects.
287287
288288
289289
.. c:function:: int PyEval_MergeCompilerFlags(PyCompilerFlags *cf)

Doc/extending/building.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ distutils; this section explains building extension modules only.
5858
It is common to pre-compute arguments to :func:`setup`, to better structure the
5959
driver script. In the example above, the\ ``ext_modules`` argument to
6060
:func:`setup` is a list of extension modules, each of which is an instance of
61-
the :class:`Extension`. In the example, the instance defines an extension named
62-
``demo`` which is build by compiling a single source file, :file:`demo.c`.
61+
the :class:`~distutils.extension.Extension`. In the example, the instance
62+
defines an extension named ``demo`` which is build by compiling a single source
63+
file, :file:`demo.c`.
6364

6465
In many cases, building an extension is more complex, since additional
6566
preprocessor defines and libraries may be needed. This is demonstrated in the

Doc/extending/extending.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -860,9 +860,9 @@ the cycle itself.
860860
The cycle detector is able to detect garbage cycles and can reclaim them so long
861861
as there are no finalizers implemented in Python (:meth:`__del__` methods).
862862
When there are such finalizers, the detector exposes the cycles through the
863-
:mod:`gc` module (specifically, the
864-
``garbage`` variable in that module). The :mod:`gc` module also exposes a way
865-
to run the detector (the :func:`collect` function), as well as configuration
863+
:mod:`gc` module (specifically, the :attr:`~gc.garbage` variable in that module).
864+
The :mod:`gc` module also exposes a way to run the detector (the
865+
:func:`~gc.collect` function), as well as configuration
866866
interfaces and the ability to disable the detector at runtime. The cycle
867867
detector is considered an optional component; though it is included by default,
868868
it can be disabled at build time using the :option:`--without-cycle-gc` option

Doc/extending/newtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ This is so that Python knows how much memory to allocate when you call
137137
If you want your type to be subclassable from Python, and your type has the same
138138
:c:member:`~PyTypeObject.tp_basicsize` as its base type, you may have problems with multiple
139139
inheritance. A Python subclass of your type will have to list your type first
140-
in its :attr:`__bases__`, or else it will not be able to call your type's
140+
in its :attr:`~class.__bases__`, or else it will not be able to call your type's
141141
:meth:`__new__` method without getting an error. You can avoid this problem by
142142
ensuring that your type has a larger value for :c:member:`~PyTypeObject.tp_basicsize` than its
143143
base type does. Most of the time, this will be true anyway, because either your

0 commit comments

Comments
 (0)