Skip to content

[3.11] gh-107298: Fix some references in the C API documentation (GH-108072) #108076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/c-api/typeobj.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ and :c:data:`PyType_Type` effectively act as defaults.)
to a pointer, are valid C99 address constants.

However, the unary '&' operator applied to a non-static variable
like :c:func:`PyBaseObject_Type` is not required to produce an address
like :c:data:`PyBaseObject_Type` is not required to produce an address
constant. Compilers may support this (gcc does), MSVC does not.
Both compilers are strictly standard conforming in this particular
behavior.
Expand Down
4 changes: 2 additions & 2 deletions Doc/extending/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ needed to ensure that it will not be discarded, causing :c:data:`!SpamError` to
become a dangling pointer. Should it become a dangling pointer, C code which
raises the exception could cause a core dump or other unintended side effects.

We discuss the use of ``PyMODINIT_FUNC`` as a function return type later in this
We discuss the use of :c:macro:`PyMODINIT_FUNC` as a function return type later in this
sample.

The :exc:`!spam.error` exception can be raised in your extension module using a
Expand Down Expand Up @@ -363,7 +363,7 @@ only non-\ ``static`` item defined in the module file::
return PyModule_Create(&spammodule);
}

Note that PyMODINIT_FUNC declares the function as ``PyObject *`` return type,
Note that :c:macro:`PyMODINIT_FUNC` declares the function as ``PyObject *`` return type,
declares any special linkage declarations required by the platform, and for C++
declares the function as ``extern "C"``.

Expand Down
4 changes: 2 additions & 2 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -679,8 +679,8 @@ Extensions defined after the ``*shared*`` marker are built as dynamic libraries.
The :file:`setup.py` script only builds C extensions as shared libraries using
the :mod:`distutils` module.

The :c:macro:`PyAPI_FUNC()`, :c:macro:`PyAPI_API()` and
:c:macro:`PyMODINIT_FUNC()` macros of :file:`Include/pyport.h` are defined
The :c:macro:`PyAPI_FUNC()`, :c:macro:`PyAPI_DATA()` and
:c:macro:`PyMODINIT_FUNC` macros of :file:`Include/pyport.h` are defined
differently depending if the ``Py_BUILD_CORE_MODULE`` macro is defined:

* Use ``Py_EXPORTED_SYMBOL`` if the ``Py_BUILD_CORE_MODULE`` is defined
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/2.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ code, none of the changes described here will affect you very much.
definition tables to simplify implementation of methods with no arguments or a
single untyped argument. Calling such methods is more efficient than calling a
corresponding method that uses :c:macro:`METH_VARARGS`. Also, the old
:c:macro:`METH_OLDARGS` style of writing C methods is now officially deprecated.
:c:macro:`!METH_OLDARGS` style of writing C methods is now officially deprecated.

* Two new wrapper functions, :c:func:`PyOS_snprintf` and :c:func:`PyOS_vsnprintf`
were added to provide cross-platform implementations for the relatively new
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/2.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,7 @@ Changes to Python's build process and to the C API include:
(:file:`libpython2.3.so`) by supplying :option:`!--enable-shared` when running
Python's :program:`configure` script. (Contributed by Ondrej Palkovsky.)

* The :c:macro:`DL_EXPORT` and :c:macro:`DL_IMPORT` macros are now deprecated.
* The :c:macro:`!DL_EXPORT` and :c:macro:`!DL_IMPORT` macros are now deprecated.
Initialization functions for Python extension modules should now be declared
using the new macro :c:macro:`PyMODINIT_FUNC`, while the Python core will
generally use the :c:macro:`PyAPI_FUNC` and :c:macro:`PyAPI_DATA` macros.
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/2.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ Some of the changes to Python's build process and to the C API are:
:c:func:`PyArg_ParseTupleAndKeywords` but takes a :c:type:`va_list` instead of a
number of arguments. (Contributed by Greg Chapman.)

* A new method flag, :c:macro:`METH_COEXISTS`, allows a function defined in slots
* A new method flag, :c:macro:`METH_COEXIST`, allows a function defined in slots
to co-exist with a :c:type:`PyCFunction` having the same name. This can halve
the access time for a method such as :meth:`set.__contains__`. (Contributed by
Raymond Hettinger.)
Expand Down
6 changes: 3 additions & 3 deletions Doc/whatsnew/2.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3060,9 +3060,9 @@ Changes to Python's build process and to the C API include:

* Some macros were renamed in both 3.0 and 2.6 to make it clearer that
they are macros,
not functions. :c:macro:`Py_Size()` became :c:macro:`Py_SIZE()`,
:c:macro:`Py_Type()` became :c:macro:`Py_TYPE()`, and
:c:macro:`Py_Refcnt()` became :c:macro:`Py_REFCNT()`.
not functions. :c:macro:`!Py_Size()` became :c:macro:`Py_SIZE()`,
:c:macro:`!Py_Type()` became :c:macro:`Py_TYPE()`, and
:c:macro:`!Py_Refcnt()` became :c:macro:`Py_REFCNT()`.
The mixed-case macros are still available
in Python 2.6 for backward compatibility.
(:issue:`1629`)
Expand Down
12 changes: 6 additions & 6 deletions Doc/whatsnew/2.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2286,10 +2286,10 @@ object, and then get the ``void *`` pointer, which will usually point
to an array of pointers to the module's various API functions.

There is an existing data type already used for this,
:c:type:`PyCObject`, but it doesn't provide type safety. Evil code
:c:type:`!PyCObject`, but it doesn't provide type safety. Evil code
written in pure Python could cause a segmentation fault by taking a
:c:type:`PyCObject` from module A and somehow substituting it for the
:c:type:`PyCObject` in module B. Capsules know their own name,
:c:type:`!PyCObject` from module A and somehow substituting it for the
:c:type:`!PyCObject` in module B. Capsules know their own name,
and getting the pointer requires providing the name:

.. code-block:: c
Expand All @@ -2309,10 +2309,10 @@ detect the mismatched name and return false. Refer to
:ref:`using-capsules` for more information on using these objects.

Python 2.7 now uses capsules internally to provide various
extension-module APIs, but the :c:func:`PyCObject_AsVoidPtr` was
extension-module APIs, but the :c:func:`!PyCObject_AsVoidPtr` was
modified to handle capsules, preserving compile-time compatibility
with the :c:type:`CObject` interface. Use of
:c:func:`PyCObject_AsVoidPtr` will signal a
with the :c:type:`!PyCObject` interface. Use of
:c:func:`!PyCObject_AsVoidPtr` will signal a
:exc:`PendingDeprecationWarning`, which is silent by default.

Implemented in Python 3.1 and backported to 2.7 by Larry Hastings;
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ to the C API.
* Renamed the boolean conversion C-level slot and method:
``nb_nonzero`` is now ``nb_bool``.

* Removed :c:macro:`METH_OLDARGS` and :c:macro:`WITH_CYCLE_GC` from the C API.
* Removed :c:macro:`!METH_OLDARGS` and :c:macro:`!WITH_CYCLE_GC` from the C API.

.. ======================================================================

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ Changes to Python's build process and to the C API include:

(Contributed by Mark Dickinson; :issue:`5914`.)

* Added :c:type:`PyCapsule` as a replacement for the :c:type:`PyCObject` API.
* Added :c:type:`PyCapsule` as a replacement for the :c:type:`!PyCObject` API.
The principal difference is that the new type has a well defined interface
for passing typing safety information and a less complicated signature
for calling a destructor. The old type had a problematic API and is now
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2656,7 +2656,7 @@ require changes to your code:
* "t#" format has been removed: use "s#" or "s*" instead
* "w" and "w#" formats has been removed: use "w*" instead

* The :c:type:`PyCObject` type, deprecated in 3.1, has been removed. To wrap
* The :c:type:`!PyCObject` type, deprecated in 3.1, has been removed. To wrap
opaque C pointers in Python objects, the :c:type:`PyCapsule` API should be used
instead; the new type has a well-defined interface for passing typing safety
information and a less complicated signature for calling a destructor.
Expand Down